Re: NSMenuItem’s userKeyEquivalent lost if changing title
Re: NSMenuItem’s userKeyEquivalent lost if changing title
- Subject: Re: NSMenuItem’s userKeyEquivalent lost if changing title
- From: Dave Lyons <email@hidden>
- Date: Tue, 20 Sep 2016 00:11:26 -0700
(Ooh! I know that one!)
The custom shortcut for Finder's File > Compress menu item continues to work, because Finder goes slightly out if its way to achieve it. The item's -title remains unchanged as ”Compress”, even when you see "Compress “foo”" or "Compress 42 Items” -- in that case, you're seeing the -attributedTitle. (Ditto for "Burn to Disc…” item.)
Small downside: If you look carefully while the menu item is disabled, it looks a bit different from other disabled menu items.
--Dave
> On Sep 19, 2016, at 10:59:32 PM, Allan Odgaard <email@hidden> wrote:
>
> Some menu items use titles dynamically updated in validateMenuItem: (based on application state, like if there are selected content).
>
> This seems to be incompatible with System Preferences → Keyboard → Shortcuts → App Shortcuts, as the menu item check for custom bindings using their current title rather than original title.
>
> I notice however that Finder is not affected by this. For example if I add a custom shortcut for “Compress” then this it still work with selected content (which updates the menu item’s title).
>
> Anyone know how to go about handling dynamic menu item titles and still support custom app shortcuts?
> _______________________________________________
>
> 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
_______________________________________________
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