开发者

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜