Re: Setting key equivalent for menus depending on window
Re: Setting key equivalent for menus depending on window
- Subject: Re: Setting key equivalent for menus depending on window
- From: Charles Srstka <email@hidden>
- Date: Sat, 19 Oct 2013 15:12:04 -0500
On Oct 19, 2013, at 12:28 PM, Martin Hewitson <email@hidden> wrote:
> OK, so the idea is,
>
> + validateMenuItem in app delegate gets a first shot at setting the keyboard shortcuts
> + I override validateMenuItem in my tabbed window and reset the keyboard shortcuts
> + Other windows stick with the settings arranged by the app delegate
>
> Did I understand correctly?
validateMenuItem: isn't going to work. It only gets called when the menu item in question is revealed, usually by the user clicking on the menu containing it. You can verify this yourself by putting a log in validateMenuItem: and seeing when it gets logged. Presumably, you want your shortcuts to work even if the user hasn't clicked on any of the menus yet, which means you want to set them somewhere other than validateMenuItem:.
I'd probably go with the windowDid(Become)|(Resign)Key: methods myself. Unless the menu is somehow displayed at the same time as the window's focus is changing, windowDidResignKey: and validateMenuItem: shouldn't be part of the same session (other than if the window lost focus because the user selected "Close" from the menu bar, but in that case validateMenuItem: would be called before the item was even selected). It's possible that there could be some scenario that I'm overlooking, though, in which case someone will hopefully chime in.
Charles
_______________________________________________
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