Updating the main menu
Updating the main menu
- Subject: Updating the main menu
- From: Eric Wang <email@hidden>
- Date: Mon, 10 Nov 2003 14:02:45 -0500
I need to add and remove items from the main menu of my application
depending on whether or not a certain window is key. Calling
-insertItem:atIndex: and -removeItem: on the main menu works for the most
part, however there seems to be a delay before the menu bar actually
updates.
If I switch windows quickly enough, the menu bar never shows the menu items
I've added. This also causes a problem when switching to my application from
another application. The menu bar is updated twice - once to reflect the
static menu items in my MainMenu.nib, and another time to reflect the items
I've programmatically added.
Is there any way to force the main menu to update immediately? I've tried
just about every combination of
-[NSMenu update]
-[NSMenu sizeToFit]
-[NSMenu setMenuChangedMessagesEnabled:]
-[NSApplication setWindowsNeedUpdate:]
-[NSApplication updateWindows]
-[NSApplication setMainMenu:]
I can think of, but nothing seems to work. Calling [NSMenu
setMenuBarVisible: NO] and then [NSMenu setMenuBarVisible: YES] works, but
there is a side effect causing the display to flicker.
Any ideas or pointers in the right direction appreciated.
Eric Wang
_______________________________________________
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.