Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decoding integer and other masks in Cocoa

Cocoa has a plethora of integer masks and codes. For instance, NSCommandKeyMask or NSF1FunctionKey, which are clearly defined and documented in the headers.

However, some can be archaic and when accessing accessibility attributes, for instance to get the glyph (AXMenuItemCmdGlyph), you're given an integer number like 111, which represents F1 (0xf704), or 112 which represents F2 (hex: 0xf705).

Is there an easy way to deal with masks and codes? Perhaps one that's able to convert the 111 into the corresponding hex unicode 0xf704? What I mean is that NSEvent.h maps NSF1FunctionKey to 0xf704, but is there a mapping for 111 to NSF1FunctionKey or 0xf704?

like image 746
the979kid Avatar asked Jul 24 '10 14:07

the979kid


1 Answers

If you want the Unicode character for the menu item's key equivalent, rather than the glyph for it, try getting the kAXMenuItemCmdCharAttribute attribute instead of kAXMenuItemCmdGlyphAttribute.

like image 93
Peter Hosey Avatar answered Nov 15 '22 18:11

Peter Hosey