Re: NSDocument-oriented app and -keydown
Re: NSDocument-oriented app and -keydown
- Subject: Re: NSDocument-oriented app and -keydown
- From: Richard Somers <email@hidden>
- Date: Thu, 29 Sep 2011 11:12:32 -0600
On Sep 29, 2011, at 8:42 AM, Nick wrote:
> how can I get a keydown (and keyup) events in an NSDocument-oriented
> application for a particular document's window?
> I'd like to get a control activated/deactivated on the window, depending on
> whether the specific key is pressed or released.
Key events are passed along the responder chain. The document window delegate is in the responder chain and will respond to -keyDown:, -keyUp:, and -flagsChanged: events. You could subclass NSWindowController and make it the delegate of your document window and handle the events there.
NSWindowController Class Reference documentation has a nice paragraph on subclassing.
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/Reference/Reference.html
Document-Based Applications Overview documentation also has a section on "Should I subclass NSWindowController?"
http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Documents/Tasks/FAQ.html#//apple_ref/doc/uid/20000954-1080900
If you need custom handling of modifier keys at the application level or absolutely need all key up events you could subclass NSApplication and override the -sendEvent: method.
--Richard
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden