mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +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
a9013a2c26
commit
063b64fd78
1 changed files with 17 additions and 5 deletions
|
@ -313,17 +313,29 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
objectForKey: @"NSMenuItemIndex"] intValue];
|
objectForKey: @"NSMenuItemIndex"] intValue];
|
||||||
NSMenuItem *anItem = [_items_link objectAtIndex: index];
|
NSMenuItem *anItem = [_items_link objectAtIndex: index];
|
||||||
id aCell = [NSMenuItemCell new];
|
id aCell = [NSMenuItemCell new];
|
||||||
|
int wasHighlighted = _highlightedItemIndex;
|
||||||
|
|
||||||
[aCell setMenuItem: anItem];
|
[aCell setMenuItem: anItem];
|
||||||
[aCell setMenuView: self];
|
[aCell setMenuView: self];
|
||||||
[aCell setFont: _font];
|
[aCell setFont: _font];
|
||||||
|
|
||||||
if ([self highlightedItemIndex] == index)
|
/* Unlight the previous highlighted cell if the index of the highlighted
|
||||||
[aCell setHighlighted: YES];
|
* cell will be ruined up by the insertion of the new cell. */
|
||||||
else
|
if (wasHighlighted >= index)
|
||||||
[aCell setHighlighted: NO];
|
{
|
||||||
|
[self setHighlightedItemIndex: -1];
|
||||||
|
}
|
||||||
|
|
||||||
[_itemCells insertObject: aCell atIndex: index];
|
[_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];
|
[aCell setNeedsSizing: YES];
|
||||||
RELEASE(aCell);
|
RELEASE(aCell);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue