On Mar 18, 2014, at 13:16:31, Jim Prouty <j...@wavemetrics.com> wrote:

> Because menuHasKeyEquivalent:forEvent:target:action: is asking only menu(s) 
> it knows about whether they contain the key equivalent, and we very likely 
> are about to change which menu/menu item has that key equivalent with our 
> just-in-time approach (the MenuSelect method from Carbon).
> 
> We need a chance to change all the menus and menu items and force Cocoa to 
> look at them all for where the key equivalent is used after those changes.
> 
> For example, command-A can be assigned to “Select All” in the Edit menu for 
> most active (key) windows or to “Autoscale” in the Graph menu for active 
> graph windows.
> 
> We need a chance to make that change (and many others like it). Mostly to get 
> Cocoa to check the right menus for the key equivalent.
> 
> Right now we’re not getting calls to 
> menuHasKeyEquivalent:forEvent:target:action: when command-A is pressed unless 
> the menu is clicked/populated.

We have a very similar situation where different tools will add their own 
menus, and some of those menus share key equivs with normal menus (like 
command-a). We'll remove those key equivs from the normal menus, remember them 
in a list, and set the new menu item's key equiv.

One thing we ended up doing was handling menuNeedsUpdate in the app delegate 
AND handling windowDidBecomeMain for all windows in the app delegate. Both call 
the same method that set the key equivs and the enabled state of all items in 
the current tool menu. BTW, our tool menus have the "Auto Enables Items" 
checkbox turned off in the xib, because their enable state is controlled by 
some cross-platform code.

We've also had to add a subclass of NSMenu that overrides performKeyEquivalent 
because the default behavior doesn't handle all key/modifier combinations 
correctly, especially some non-modifed or non-command-key key equivs.

--
Steve Mills
office: 952-818-3871
home: 952-401-6255


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to