Re: Handling key equivalents in a controller class?
Re: Handling key equivalents in a controller class?
- Subject: Re: Handling key equivalents in a controller class?
- From: Matt Neuburg <email@hidden>
- Date: Mon, 21 Jul 2008 12:13:03 -0700
- Thread-topic: Handling key equivalents in a controller class?
On Sat, 19 Jul 2008 12:34:45 -0700, Jens Alfke <email@hidden> said:
>
>On 19 Jul '08, at 8:52 AM, Matt Neuburg wrote:
>
>> Try it and see. Let's say we want to catch Esc directed to the
>> window as a
>> whole (to exit full screen mode, if I recall your example). So what
>> I would
>> do is to insert an NSResponder instance behind the window in the
>> chain and
>> implement keyDown:.
>
>I had already tried implementing keyDown: in my controller object,
>which is the window's delegate, to no avail. But that class is just a
>direct subclass of NSObject, not NSResponder or NSWindowController. I
>tried changing its superclass to NSResponder, but that didn't help.
>
>Looks like I need to read up on the conceptual docs about the
>responder chain, to figure out how to make my object the window's next
>responder. (I've never manipulated the chain directly before.)
Well, as Solon used to say, "You learn something new every day, even if you
don't want to!" A good place to start might be here:
http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/Hand
lingKeyEvents/chapter_6_section_3.html
As for inserting your own objects into the responder chain, this is a
technique I've discussed here many times, most recently just last week:
http://www.cocoabuilder.com/archive/message/cocoa/2008/7/14/212862
I used to do quite a bit of NSWindow subclassing (and if you look on the
archives you'll find me arguing for it in those days), but these days I lean
much more towards inserting singleton NSResponders into the responder chain.
If I want to modify the keyboard behavior of a particular view in a window,
such as a table view, I insert the NSResponder behind it. If I want to
modify the keyboard behavior related to a window as a whole, I insert the
NSResponder behind the window. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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