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

Problem with NSMenu -addItem and -removeItem


  • Subject: Problem with NSMenu -addItem and -removeItem
  • From: Andreas Schweizer <email@hidden>
  • Date: Tue, 4 Sep 2001 23:15:21 +0200

Hi list,

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?

Thanks, Andy


  • Follow-Ups:
    • Re: Problem with NSMenu -addItem and -removeItem
      • From: Andrew Platzer <email@hidden>
  • Prev by Date: Re: Any advantages of Unix formatting
  • Next by Date: HTML rendering
  • Previous by thread: Re: Writing a custom spell service
  • Next by thread: Re: Problem with NSMenu -addItem and -removeItem
  • Index(es):
    • Date
    • Thread