• 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: NSCommandKeyMask being ignored in NSView subclasses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSCommandKeyMask being ignored in NSView subclasses


  • Subject: Re: NSCommandKeyMask being ignored in NSView subclasses
  • From: Andrew Farmer <email@hidden>
  • Date: Sun, 29 Jul 2007 19:42:17 -0700

On 29 Jul 07, at 18:54, Bruce Johnson wrote:
thank you for the links,
NSUndoManager doesn't work for what I'm trying to do. I am working to
implement a very specific action that NSUndoManager doesn't present an
obvious solution for, but that is a secondary issue.

I'd argue that's the *primary* issue, given that solving it would make the secondary issue (trying to intercept cmd-Z) go away. Without further information on what you're trying to do, though, I can't help.


I've created a menu with the cmd-z shortcut (or whatever cmd-key combination
I choose) in Interface builder. The action method in my controller class is
not getting called.

Probably because it's getting caught by the existing Edit:Undo menu item.


Is there a way to intercept the command-key events?

Yes. (Subclass NSApplication and override sendEvent.) However, I strongly recommend against implementing your feature that way - among other issues, Cmd-Z for undo will stop working in places that it normally works, like text fields, and the Edit:Undo menu item will behave differently from the Cmd-Z shortcut. It's also just plain ugly.


You're much better off taking a close look at how the responder chain works. If you understand this concept thoroughly, you'll see a much easier way to make the keyboard shortcut work.
_______________________________________________


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: NSCommandKeyMask being ignored in NSView subclasses
      • From: "Bruce Johnson" <email@hidden>
References: 
 >NSCommandKeyMask being ignored in NSView subclasses (From: "Bruce Johnson" <email@hidden>)
 >Re: NSCommandKeyMask being ignored in NSView subclasses (From: Andrew Farmer <email@hidden>)
 >Re: NSCommandKeyMask being ignored in NSView subclasses (From: "Bruce Johnson" <email@hidden>)

  • Prev by Date: Re: Values set in awakeFromInsert have gone missing.
  • Next by Date: duplicate help menu
  • Previous by thread: Re: NSCommandKeyMask being ignored in NSView subclasses
  • Next by thread: Re: NSCommandKeyMask being ignored in NSView subclasses
  • Index(es):
    • Date
    • Thread