Re: NSCommandKeyMask being ignored in NSView subclasses
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 16:49:49 -0700
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
_______________________________________________
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