Re: NSCommandKeyMask being ignored in NSView subclasses
Re: NSCommandKeyMask being ignored in NSView subclasses
- Subject: Re: NSCommandKeyMask being ignored in NSView subclasses
- From: "Bruce Johnson" <email@hidden>
- Date: Sun, 29 Jul 2007 19:54:29 -0600
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'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.
Is there a way to intercept the command-key events?
On 7/29/07, Andrew Farmer <email@hidden> wrote:
>
> On 29 Jul 07, at 16:27, Bruce Johnson wrote:
> > In my NSView subclass I'm trying (and failing) to implement cmd-Z
> > for undo
> > The NSCommandKeyMask in the keydown event is not being caught:
> > some code from the NSView Subclass:
> <...>
>
> Command-key events aren't passed to views - they're captured high up
> in AppKit and processed as menu shortcuts. That's a secondary issue,
> though. What's more important is that you're trying to reinvent the
> wheel. Read the documentation for NSUndoManager[1] - AppKit already
> implements a global "undo" command in a much more general fashion.
>
> There's also a separate issue lurking in your code: you're using -
> [NSEvent keyCode] inappropriately. Consider that keycodes are not
> necessarily mapped into characters the same way on all keyboard
> layouts. For example, some European countries such as France and
> Belgium use an AZERTY layout[2]. If you're going to hard-code key
> mappings (and you should generally avoid it), use -[NSEvent characters].
>
> [1]: http://developer.apple.com/documentation/Cocoa/Reference/
> Foundation/Classes/NSUndoManager_Class/
> [2]: http://en.wikipedia.org/wiki/AZERTY
>
--
----
Bruce Johnson
email@hidden
_______________________________________________
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