• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting keyDowns
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting keyDowns


  • Subject: Re: Getting keyDowns
  • From: "John C. Randolph" <email@hidden>
  • Date: Sun, 26 Aug 2001 12:30:54 -0700

On Sunday, August 26, 2001, at 11:59 AM, Rosyna wrote:

I have it set up as so.

#import "KeyHandler.h"

@implementation KeyHandler

-(void)keyDown:(NSEvent*)event
{
NSLog(@"Hi");
}

-(void)awakeFromNib
{
[window makeKeyAndOrderFront:nil];
NSLog(@"Ho");
}

First thing I'd try is to make the window the key window in -appDidInit instead of -awakeFromNib (which means that your KeyHandler instance will also need to be the App delegate), and the second thing I'd try is checking the window event mask to be sure the window's taking keydown events. IIRC, you don't need to bother doing that if there's an active text field in the window, since it should modify the event mask as necessary in its -becomeFirstResponder method.

You can get the window's event mask in the debugger with "p (int) window->_winEventMask". To check if it's taking keydowns, use "p (int) window->_winEventMask | NSKeyDownMask".

I know that in NeXTSTEP, there was a method to set the window's event mask, but I can't seem to find it in the 10.0 docs.


BTW, according to the manual:

Given all these components, then, the full responder chain comprises these objects:

 The key window's first responder and successors, including objects added with setNextResponder:
 The key window itself
 The key window's delegate (which need not inherit from NSResponder)
 The main window's first responder and successors, including objects added with setNextResponder:
 The main window itself
 The main window's delegate (which need not inherit from NSResponder)
 The application object, NSApp
 The application object's delegate (which need not inherit from NSResponder)

-jcr


"Scientology is both immoral and socially obnoxious... it is
corrupt, sinister and dangerous." - Mr. Justice Latey, London 1984


  • Follow-Ups:
    • Re: Getting keyDowns
      • From: Rosyna <email@hidden>
    • Re: Getting keyDowns
      • From: Finlay Dobbie <email@hidden>
References: 
 >Re: Getting keyDowns (From: Rosyna <email@hidden>)

  • Prev by Date: Re: Getting keyDowns
  • Next by Date: Scaling
  • Previous by thread: Re: Getting keyDowns
  • Next by thread: Re: Getting keyDowns
  • Index(es):
    • Date
    • Thread