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: Jens Alfke <email@hidden>
- Date: Sat, 19 Jul 2008 12:34:45 -0700
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.)
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,
That makes sense. I had been thinking that event handlers would need a
boolean return value to indicate whether or not they handled the
event, but I'd overlooked the behavior of calling super to pass the
event up. Thanks!
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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