Problem with NSMenu -addItem and -removeItem
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