• 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
Handling keyDown events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handling keyDown events


  • Subject: Handling keyDown events
  • From: Paolo Bertani <email@hidden>
  • Date: Fri, 5 May 2006 21:51:06 +0200

Hi,
	my app has one window which is main and key.

There is one table, some text field and so on.

Now I need to intercept some keys in order to take some action: arrow- down, cmd-space, etc...

In IB I subclassed NSWindow, creating MyWindow class. Then generated files fo MyWindow.
Selected the main window's NSWindow instance and, within the inspector, changed the custom class from NSWindow to MyWindow.
I opened the file MyWindow.c and overrided keyDown method this way:



#import "MyWindow.h"

@implementation MyWindow

-(void)keyDown:(NSEvent *)theEvent
{
	NSLog( @"keydown!" );

	[super keyDown:theEvent];
}


@end


I also edited MyWindow.h this way



/* MyWindow */

#import <Cocoa/Cocoa.h>

@interface MyWindow : NSWindow
{
}
-(void)keyDown:(NSEvent *)theEvent;

@end



Unfortunately the overrided keyDown is not called when I type on the keyboard.

What I am missing?

Thank you in advance...




"<Ai sensi e per gli effetti del D.Lgs. n.° 196/2003 (Codice della Privacy) si precisa che questo messaggio, ed eventuali relativi allegati, è strettamente riservato ai destinatari in indirizzo, con espressa diffida di conservazione, uso, copiatura o divulgazione. Chiunque lo riceva, non essendone destinatario, è pregato di avvertire lo scrivente e di provvedere alla distruzione di quanto erroneamente pervenuto>" _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Handling keyDown events
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Re: Which format for image file resources in Cocoa application?
  • Next by Date: Re: How to control the commit of text edit field with binding?
  • Previous by thread: [MEET] Next CocoaHeads coming up!
  • Next by thread: Re: Handling keyDown events
  • Index(es):
    • Date
    • Thread