On Oct 7, 2013, at 2:33 PM, Steve Mills wrote:

> Why is it that if I use the menu delegate method 
> menuHasKeyEquivalent:forEvent:target:action: to search for a key equiv in one 
> of our submenus, the action method gets called with the menu as the sender 
> instead of the menu item? I see now way to say "use this menu item as the 
> sender when you send the action to the target".
> 
> To work around this, I am simply returning NO from menuHasKeyEquivalent and 
> calling performActionForItemAtIndex: from it. Is that a valid workaround?

What exactly are you trying to do?  Are you perhaps just looking for -[NSMenu 
performKeyEquivalent:]?

The behavior of your -menuHasKeyEquivalent:... method is up to you.  Are you 
asking why your method does what it does?  We can't know.  In any case, calling 
that should not invoke the action on any target.  So: a) I don't understand 
your first paragraph, and b) the answer to your question in the second 
paragraph is NO.

The -menuHasKeyEquivalent:… delegate method is mostly not very useful.  As 
discussed in the WWDC 2010 Session 145 - Key Event Handling in Cocoa 
Applications video (around 6:55), the main use of that method is to return NO 
for menus that you know do _not_ have key equivalents, to optimize the search.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to