• 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: Matt Neuburg <email@hidden>
  • Date: Wed, 16 Jul 2008 14:53:48 -0700
  • Thread-topic: Handling key equivalents in a controller class?

On Wed, 16 Jul 2008 10:05:52 -0700, Jens Alfke <email@hidden> said:
>I've run into this problem a few times now: I have an
>NSWindowController subclass that manages a window. I want to handle
>certain hot-keys in this window, for example Esc to exit full-screen
>mode, or maybe use letter keys to switch tools as in Photoshop. Where
>do I put the handler for this?
>
>When this happened in the past I added a -performKeyEquivalent: method
>to a custom view in the window. However, this only makes sense
>architecturally if the action is related to that view; and if the view
>is a standard class (like NSTableView) then I have to subclass it just
>to add that one method. (AppKit doesn't send -performKeyEquivalent up
>the responder chain to the window's delegate, only to the views in the
>window.) This seems contrary to Cocoa's usual philosophy of delegation.
>
>Am I missing something?

Implement keyDown: in the NSWindowController? I'm not seeing a reason why
you need performKeyEquivalent to catch unmodified Esc and letter keys...
Actually I'm fond of sticking a singleton NSResponder into the chain after
the window and implementing keyDown: there. 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

  • Follow-Ups:
    • Re: Handling key equivalents in a controller class?
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: IBPlugin cannot load
  • Next by Date: Re: NSButton setKeyEquivalent doesn't seem to work
  • 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