• 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
Re: Handling key equivalents in a controller class?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Handling key equivalents in a controller class?
      • From: Nathan Vander Wilt <email@hidden>
    • Re: Handling key equivalents in a controller class?
      • From: "I. Savant" <email@hidden>
    • Re: Handling key equivalents in a controller class?
      • From: Jeff Johnson <email@hidden>
References: 
 >Re: Handling key equivalents in a controller class? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: CoreData Property access compiles, but fails at runtime
  • Next by Date: NSTimer, and NSTimeInterval help?
  • Previous by thread: Re: Handling key equivalents in a controller class?
  • Next by thread: Re: Handling key equivalents in a controller class?
  • Index(es):
    • Date
    • Thread