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: Sat, 19 Jul 2008 08:52:26 -0700
- Thread-topic: Handling key equivalents in a controller class?
On Thu, 17 Jul 2008 09:31:53 -0700, Jens Alfke <email@hidden> said:
>
>On 16 Jul '08, at 2:53 PM, Matt Neuburg wrote:
>
>> Implement keyDown: in the NSWindowController?
>
>keyDown: only gets sent to the key view, whether or not it handles
>that keystroke. Since the method returns void, there's no way for
>AppKit to tell whether a responder handled the keystroke or not, so it
>can't pass it up the chain.
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:. When an event arrives (arrives! It got here by being
handed up thru all the views and the window, which therefore clearly didn't
handle it), we look to see if it's for us - i.e., is it Esc or not. If it
is, we tell the window to do what it's supposed to do, and the event is not
handed any further up the responder chain. If not, we pass the event to
super and the event is handed on up the responder chain in the usual way,
and proceeds to the window controller and so on. I've been using this
technique for many years and haven't had any trouble with it. It seems to me
that this is just what the responder chain is for. 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