Re: Showing numpad key equivs in menu items
Re: Showing numpad key equivs in menu items
- Subject: Re: Showing numpad key equivs in menu items
- From: Allan Odgaard <email@hidden>
- Date: Wed, 08 May 2013 09:00:00 +0700
On May 8, 2013, at 7:36, "David M. Cotter" <email@hidden> wrote:
> […] filed a DTS incident for (and got some help with) custom-drawing menu items, for the express purpose of drawing an arbitrary string as the "keyboard shortcut" in menus. and i can tell you the work around was a PITA and is a bit fragile.
Would you be able to share this code?
TextMate also draws a custom string as key equivalent because of Cocoa issues. Carbon worked better but is unavailable when building as 64 bit.
TextMate’s implementation is here https://github.com/textmate/textmate/blob/master/Frameworks/OakAppKit/src/NSMenuItem Additions.mm#L170-L189 and sets the title as an attributed string using an NSTextTableBlock to have the key equivalent string show as the second column. This is fairly unobtrusive and the only (user visible) shortcoming I have found is that it doesn’t left/right align the key/modifier glyphs and writes out F1-Fn instead of using the special glyphs for these keys.
While it (presently) doesn’t do anything special for the numpad modifier, I also see value in rendering the numpad keys. In my case, the user can setup custom key bindings, and expert users do like to bind some stuff only to the numpad keys.
I should add that the reason TextMAte uses custom rendering is primarily motivated by not having NSMenuItem handle the key equivalent, as it is unaware of multi-stroke key bindings in progress (dispite being a framework feature) and because it is unable to deal with multiple menu items sharing key equivalent (when the menu items’ action differs).
_______________________________________________
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