• 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
Re: Problem with NSMenu -addItem and -removeItem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with NSMenu -addItem and -removeItem


  • Subject: Re: Problem with NSMenu -addItem and -removeItem
  • From: Andrew Platzer <email@hidden>
  • Date: Fri, 7 Sep 2001 10:37:55 -0700

On Tuesday, September 4, 2001, at 02:15 , Andreas Schweizer wrote:
I'm having a problem with the NSMenu / NSMenuItem classes. I want a certain menu to be visible in the menu bar only if a certain window is visible. To that purpose, I've implemented the two delegate messages of NSWindow:

- (void)windowDidBecomeMain:(NSNotification *)aNotification
{
[mainMenu addItem:simulationMenu];
}

- (void)windowDidResignMain:(NSNotification *)aNotification
{
[mainMenu removeItem:simulationMenu];
}

The menu is added to the menu bar when the window becomes main for the first time, and is properly removed from the menu bar when the window resigns main.

Unfortunately, this works only once. After the menu has been removed once,
it does never appear in the menu bar again :-(
(I've added code to print the [mainMenu description], and the interesting thing is that it looks all right -- the simulationMenu is correctly added and removed; it simply doesn't appear on the screen!)

Can anybody help me with that? Is there something like the old DrawMenuBar that you have to call to update the menu bar?

This was a bug in 10.0.x and has been fixed for 10.1. Unfortunately, the only workaround for 10.0.x is to create a new menu instead of adding the old one back in again.

Andrew
__________________________________________________________________
A n d r e w P l a t z e r
A p p l i c a t i o n F r a m e w o r k s
A p p l e


  • Follow-Ups:
    • Re: Problem with NSMenu -addItem and -removeItem
      • From: Andreas Schweizer <email@hidden>
References: 
 >Problem with NSMenu -addItem and -removeItem (From: Andreas Schweizer <email@hidden>)

  • Prev by Date: Re: Search for "playscore" (NeXT) to play ".score" files in OS X
  • Next by Date: Re: When Obj-C++?
  • Previous by thread: Problem with NSMenu -addItem and -removeItem
  • Next by thread: Re: Problem with NSMenu -addItem and -removeItem
  • Index(es):
    • Date
    • Thread