Fix for item removal.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5371 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-12-03 11:52:11 +00:00
parent 61e1bfe8af
commit 2806eb908b
2 changed files with 20 additions and 4 deletions

View file

@ -279,7 +279,7 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
//
// Notification Methods
//
- (void)itemChanged: (NSNotification *)notification
- (void) itemChanged: (NSNotification *)notification
{
int index = [[[notification userInfo] objectForKey: @"NSMenuItemIndex"]
intValue];
@ -291,7 +291,7 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
[self setNeedsSizing: YES];
}
- (void)itemAdded: (NSNotification *)notification
- (void) itemAdded: (NSNotification *)notification
{
int index = [[[notification userInfo]
objectForKey: @"NSMenuItemIndex"] intValue];
@ -314,13 +314,22 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
[self setNeedsSizing: YES];
}
- (void)itemRemoved: (NSNotification *)notification
- (void) itemRemoved: (NSNotification *)notification
{
int wasHighlighted = [self highlightedItemIndex];
int index = [[[notification userInfo] objectForKey: @"NSMenuItemIndex"]
intValue];
if (index <= wasHighlighted)
{
[self setHighlightedItemIndex: -1];
}
[menuv_itemCells removeObjectAtIndex: index];
if (wasHighlighted > index)
{
[self setHighlightedItemIndex: --wasHighlighted];
}
// Mark the menu view as needing to be resized.
[self setNeedsSizing: YES];
}