I'm currently overriding menuHasKeyEquivalent:forEvent:target:action:. When I 
do, the notification for NSMenuWillSendActionNotification doesn't contain the 
menu item like the docs say it should, and I need the item in this case because 
I need its representedObject. I assume this is because menuHasKeyEquivalent 
doesn't let the standard key equiv handling mechanism know which menu item was 
found - only the target and action are returned. This seems like a big flaw in 
the whole thing.

I'm overriding menuHasKeyEquivalent because matching key equivs is still buggy 
when it comes to menus that need to be rebuilt after switching document 
windows. And by buggy I mean it still isn't smart enough to always call 
menuNeedsUpdate: when menuHasKeyEquivalent is NOT overridden. I sure had hoped 
that this would've been fixed by now, as I recall running into this same 
problem a couple years ago in Finale. Arg.

Even calling [[NSApp mainMenu] update] doesn't always fix the problem. Here's a 
scenario:

Have 2 docs open.
Doc 1 causes a menu item in a dynamic menu to have a key equiv (it even uses 
the command key).
Doc 2 has no items with key equivs in the same dynamic menu.
Switch to doc 1 and hit that equiv. It works.
Switch to doc 2 and hit that equiv. It does nothing, which is correct.
Switch to doc 1 and hit that equiv. Nothing happens - menuNeedsUpdate: is NOT 
called.

Is there any reliable way to force the menus to be correctly updated?

To work around it, I'm having my menuHasKeyEquivalent method store the found 
menu item, which I can then ask for later in the action handler for that menu 
item.

--
Steve Mills
Drummer, Mac geek


_______________________________________________

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