• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Updating the main menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Updating the main menu
      • From: Stéphane Sudre <email@hidden>
    • Re: Updating the main menu
      • From: j o a r <email@hidden>
  • Prev by Date: Re: NSButton w Image not redrawing
  • Next by Date: Re: DataSource class of NSTableView - weird
  • Previous by thread: Re: Separator bar in NSMenu
  • Next by thread: Re: Updating the main menu
  • Index(es):
    • Date
    • Thread