mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-15 04:54:29 +00:00
Change how menu items are highlighted
This replaces the previous solution with one proposed by @BlairDuncan. It uses the _highlightItemAtIndex: method to maintain the highlight state, rather than setting the _highlightIndex variable directly.
This commit is contained in:
1 parent
cc9ff15142
commit
efa2918ce9
1 file changed
+3
-12
+3
-12
@@ -328,9 +328,6 @@ var _CPMenuBarVisible = NO,
|
||||
*/
|
||||
- (void)removeItem:(CPMenuItem)aMenuItem
|
||||
{
|
||||
if ([aMenuItem isHighlighted])
|
||||
[[aMenuItem _menuItemView] highlight:NO];
|
||||
|
||||
[self removeItemAtIndex:[_items indexOfObjectIdenticalTo:aMenuItem]];
|
||||
}
|
||||
|
||||
@@ -358,12 +355,7 @@ var _CPMenuBarVisible = NO,
|
||||
while (count--)
|
||||
[_items[count] setMenu:nil];
|
||||
|
||||
// See Issue 1899. Ensure the highlight state of the underlying
|
||||
// _CPMenuItemView is set to NO as well.
|
||||
if (_highlightedIndex !== CPNotFound)
|
||||
[[_items[_highlightedIndex] _menuItemView] highlight:NO];
|
||||
|
||||
_highlightedIndex = CPNotFound;
|
||||
[self _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
// Because we are changing _items directly, be sure to notify KVO
|
||||
[self willChangeValueForKey:@"items"];
|
||||
@@ -1159,6 +1151,7 @@ var _CPMenuBarVisible = NO,
|
||||
return;
|
||||
|
||||
[aMenuItem setMenu:self];
|
||||
[self _highlightItemAtIndex:CPNotFound];
|
||||
[_items insertObject:aMenuItem atIndex:anIndex];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
@@ -1172,10 +1165,8 @@ var _CPMenuBarVisible = NO,
|
||||
if (anIndex < 0 || anIndex >= [_items count])
|
||||
return;
|
||||
|
||||
if (_highlightedIndex === anIndex)
|
||||
[[[_items objectAtIndex:anIndex] _menuItemView] highlight:NO];
|
||||
|
||||
[[_items objectAtIndex:anIndex] setMenu:nil];
|
||||
[self _highlightItemAtIndex:CPNotFound];
|
||||
[_items removeObjectAtIndex:anIndex];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
|
||||
Reference in new issue
Block a user