views:

141

answers:

1

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?

+1  A: 

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.

Peter Hosey
I'm looking for the glyphs, kAXMenuItemCmdCharAttribute will give null for anything other than characters. Anyway, the best thing I found was to basically map the glyph codes (111, etc) given by the AXMenuItemCmdGlyph attribute to their unicode/NSEvent.h equivalents. There does not seems to be any relationship between the accessibility codes given to glyphs and the actual unicodes for these glyphs as given in NSEvent.h.If someone knows better, please share.
the979kid
If you want to compare to the character constants, then you're looking for characters. What's an example of a menu item that has a `CmdGlyph` but not a `CmdChar`?
Peter Hosey