Fix for actions not being sent in submenus.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2009-12-03 00:42:13 -08:00
1 parent b0acc13da7
commit f250373673
4 files changed
+21 -14

No files matched your search

+12 -7
View File
@@ -639,6 +639,17 @@ var _CPMenuBarVisible = NO,
return _minimumWidth;
}
- (void)_performActionOfHighlightedItemChain
{
var highlightedItem = [self highlightedItem];
while ([highlightedItem submenu] && [highlightedItem action] === @selector(submenuAction:))
highlightedItem = [[highlightedItem submenu] highlightedItem];
if (highlightedItem)
[CPApp sendAction:[highlightedItem action] to:[highlightedItem target] from:highlightedItem];
}
//
+ (CGRect)_constraintRectForView:(CPView)aView
{
@@ -712,13 +723,7 @@ var aFont = nil;
if (aCallback)
aCallback(aMenu);
var highlightedItem = [aMenu highlightedItem];
while ([highlightedItem submenu] && [highlightedItem action] === @selector(submenuAction:))
highlightedItem = [[highlightedItem submenu] highlightedItem];
if (highlightedItem)
[CPApp sendAction:[highlightedItem action] to:[highlightedItem target] from:highlightedItem];
[aMenu _performActionOfHighlightedItemChain];
}
}
+8 -4
View File
@@ -41,7 +41,12 @@ var _CPMenuBarWindowBackgroundColor = nil,
var bundle = [CPBundle bundleForClass:self];
_CPMenuBarWindowFont = [CPFont boldSystemFontOfSize:13.0];
_CPMenuBarWindowFont = [CPFont boldSystemFontOfSize:12.0];
}
+ (CPFont)font
{
return _CPMenuBarWindowFont;
}
- (id)init
@@ -71,7 +76,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
[contentView addSubview:_iconImageView];
_titleField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[_titleField setFont:[CPFont boldSystemFontOfSize:13.0]];
[_titleField setAlignment:CPCenterTextAlignment];
[_titleField setTextShadowOffset:CGSizeMake(0, 1)];
@@ -262,7 +267,6 @@ var _CPMenuBarWindowBackgroundColor = nil,
_menuItemViews.push(menuItemView);
[menuItemView setFont:_CPMenuBarWindowFont];
[menuItemView setTextColor:_textColor];
[menuItemView setHidden:[item isHidden]];
@@ -293,7 +297,6 @@ var _CPMenuBarWindowBackgroundColor = nil,
[_menuItemViews insertObject:menuItemView atIndex:index];
[menuItemView setFont:_CPMenuBarWindowFont];
[menuItemView setTextColor:_textColor];
[menuItemView setHidden:[menuItem isHidden]];
@@ -328,6 +331,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
constraintRect:constraintRect
callback:function(aMenuContainer, aMenu)
{
[aMenu _performActionOfHighlightedItemChain];
[aMenu _highlightItemAtIndex:CPNotFound];
}];
}
-2
View File
@@ -274,8 +274,6 @@ var SharedMenuManager = nil;
if ([menuContainer menu] === baseMenu)
break;
[[menuContainer menu] _highlightItemAtIndex:CPNotFound];
[menuContainer orderOut:self];
[menuContainer setMenu:nil];
+1 -1
View File
@@ -100,7 +100,7 @@ var SelectionColor = nil,
var x = HORIZONTAL_MARGIN,
height = 0.0;
[_imageAndTextView setFont:[_menuItem font] || _font];
[_imageAndTextView setFont:[_menuItem font] || [_CPMenuBarWindow font]];
[_imageAndTextView setVerticalAlignment:CPCenterVerticalTextAlignment];
[_imageAndTextView setImage:[_menuItem image]];
[_imageAndTextView setText:[_menuItem title]];