How to detect main menu being opened
How to detect main menu being opened
- Subject: How to detect main menu being opened
- From: Doug F <email@hidden>
- Date: Tue, 20 Mar 2007 13:17:20 -0400
Hello all,
Is there any API that will tell me when the user has opened any of
the main menu bar's menus (including the Apple menu)? I want to
"pause" my application's timers and update some state when this
occurs, but I haven't figured out a reliable way.
My first idea almost worked for all menus except the system-Apple
menu. I set up a delegate for each menu and implemented
- (void)menuNeedsUpdate:(NSMenu *)menu
which then called my "pause" routine. (Incidentally, setting the
delegate of the whole main menu did NOT ever call the above routine;
I had to set the delegate of each menu individually in Interface
Builder.)
This failed because one of my menu items was a "Pause" menu with a
hotkey. As it turns out, hitting this hotkey causes "menuNeedsUpdate"
to be invoked prior to the target/action being called, which pauses
things and updates the menu to modify the menu item to be a
"resume" (with the same hotkey (modifies the title only)), so when
the hotkey target/action was called, that turned right around and
unpaused things! That was a fun thing to figure out.
Bigger picture, though: It also fails because there is no way to
determine if the system-Apple menu has been opened.
So, I need a way to generate some sort of event or target/action when
ANY menu is opened (via click or, even, Control-F2 to focus on the
menu bar) so I can pause my application.
Would anyone have any ideas, please? I've looked at the PDFs of Apple
docs, Googled and Cocoadev'd and Cocoabuildered and either my search
abilities suck or I'm just oblivious.
Thanks for your consideration.
Cheers,
Doug
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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