mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Fixed highlighting of cells when new cells are added
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@13955 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
859bb53e45
commit
fe02fe8b6e
1 changed files with 17 additions and 5 deletions
|
@ -313,17 +313,29 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
|||
objectForKey: @"NSMenuItemIndex"] intValue];
|
||||
NSMenuItem *anItem = [_items_link objectAtIndex: index];
|
||||
id aCell = [NSMenuItemCell new];
|
||||
int wasHighlighted = _highlightedItemIndex;
|
||||
|
||||
[aCell setMenuItem: anItem];
|
||||
[aCell setMenuView: self];
|
||||
[aCell setFont: _font];
|
||||
|
||||
if ([self highlightedItemIndex] == index)
|
||||
[aCell setHighlighted: YES];
|
||||
else
|
||||
[aCell setHighlighted: NO];
|
||||
|
||||
/* Unlight the previous highlighted cell if the index of the highlighted
|
||||
* cell will be ruined up by the insertion of the new cell. */
|
||||
if (wasHighlighted >= index)
|
||||
{
|
||||
[self setHighlightedItemIndex: -1];
|
||||
}
|
||||
|
||||
[_itemCells insertObject: aCell atIndex: index];
|
||||
|
||||
/* Restore the highlighted cell, with the new index for it. */
|
||||
if (wasHighlighted >= index)
|
||||
{
|
||||
/* Please note that if wasHighlighted == -1, it shouldn't be possible
|
||||
* to be here. */
|
||||
[self setHighlightedItemIndex: ++wasHighlighted];
|
||||
}
|
||||
|
||||
[aCell setNeedsSizing: YES];
|
||||
RELEASE(aCell);
|
||||
|
||||
|
|
Loading…
Reference in a new issue