Re: Updating the main menu
Re: Updating the main menu
- Subject: Re: Updating the main menu
- From: "M. Uli Kusterer" <email@hidden>
- Date: Tue, 11 Nov 2003 01:39:23 +0100
At 19:01 Uhr -0500 10.11.2003, Eric Wang wrote:
Thanks for your response. I tried that method, but unfortunately, the delay
in updating the main menu still exists. The behavior I'm looking for seems
to be possible within Cocoa. For example, switching between applications
rapidly by repeatedly pressing command-tab causes the menu bar to update
instantaneously. However, I can't seem to get that behavior by calling
-[NSApplication setMainMenu:], which I'm guessing is what Cocoa apps call to
update the main menu when they become the active application.
I don't think applications share a common menu bar. AFAIK the menu
bar is just another window in your application these days (at least
on the Window Server level, it probably isn't an NSWindow), and
whatever application is frontmost shows its "menu bar window".
In any case, I've been pouring over the Carbon documentation, and there are
some promising functions in the Menu Manager reference such as SetMenuBar()
and DrawMenuBar(). I'm not too experienced with Carbon, so if anyone knows
I'm going in the wrong direction with this, please let me know.
DrawMenuBar() could be what you want, if the problem really is that
the drawing isn't triggered immediately. At least if the rumors are
true that Cocoa's menus are implemented using the same code Carbon
uses. SetMenuBar() expects a Handle to a menu list data structure,
which you can only get using other Carbon Menu Manager calls, and
which needs to load the menus from a resource file, which you
definitely don't want to do.
May I join in and urge you not to do this, however? Mac users are
used to the menu bar staying the same. If menus appear and disappear
at the switch of a window, they'll be surprised, and it may ruin
their "muscle memory" when other menus move because one to their left
disappeared. On the Mac, the usual way to handle menu changes inside
the application is to have all items present but to disable (i.e.
grey out) the menus and menu items that aren't applicable right now.
The only occasion on which menus should actually change like that is
when switching between several applications, and that you're trying
to do this could imply that you have merged several applications into
one. It may be smarter to split up your application into several.
If you don't believe me, read Apple's (Aqua) Human Interface
Guidelines. they detail all of the reasons why this is frowned upon.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.