Re: manual item enabling


Graham Cox
 

Kurt,

The menu key equivalents are pulled out before -keyDown: is called. You can override that event in -performKeyEquivalent:, a methof of NSResponder (and therefore views, etc). You can probably call your menu update method and then call super to handle the key equivalent.

I recall the menu update mechanism from TCL very well, and I don’t think it’s a terrible way to do it, but certainly it’s a little different in Cocoa. You might find that converting your code to use -validateMenuItem: is not as bad as you’d think though, it’s broadly similar to the TCL way, just you get each menu item passed in turn, rather than the whole menu. But the code in that method deals with all of the menu items applicable to the receiving object, just like the TCL way does, and then punts any others to the next responder.

—Graham

On 25 Nov 2019, at 8:28 am, Kurt Bigler via Cocoa-dev <cocoa-dev@lists.apple.com> wrote:

The last possible moment for key equivalents is a keyDown event. Unfortunately Cocoa doesn't seem to let me catch this event and act on it to update menus prior to key equivalent processing.

-Kurt Bigler
_______________________________________________

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/graham.cox%40bigpond.com

This email sent to graham.cox@bigpond.com

Join cocoa@apple-dev.groups.io to automatically receive all group messages.