Where i find a list of Key Equivalent strings on MacOSX
I need to know which NSString values i can use for key equivalents.
I can't find out what to use for
- cursor keys
- delete/backspace
- function keys
- numpa开发者_高级运维d items
See Button Programming Topics: Setting a Button’s Key Equivalent:
https://developer.apple.com/library/mac/documentation/cocoa/conceptual/Button/Tasks/SettingButtonKeyEquiv.html
For a single character:
[button setKeyEquivalent:@"\r"];
For a non-print character:
unichar left = NSLeftArrowFunctionKey;
[button setKeyEquivalent:[NSString stringWithCharacters:&left length:1]];
Buttons and menu items use the same APIs for key equivalents.
Each of the key equivalent strings is simply the character that the key enters. For the text-editing keys, there are symbolic constants for each character defined in NSText.h and documented in NSText's documentation. Use [NSString stringWithFormat:@"%C", desiredCharacterGoesHere]
to convert these to NSStrings for use with objects such as NSMenuItems.
The same goes for the keys on the numeric keypad, which aren't distinguished from their cousins in the main keyboard. We are dealing with characters here, after all, and both sets of keys enter the same characters. I don't think there is a way to set a menu's key code rather than its key-equivalent character; you would need to implement this yourself.
Note that “delete” (as the opposite of backspace) is called “forward delete” on the Mac, as backspace is usually called delete.
精彩评论