From 3776a7bee1018e5ec8a0bcebe7013d458f16a1df Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Sat, 4 Dec 2010 10:43:34 -0800 Subject: [PATCH] Fix for invisible toolbar items sending their associated menu item as the sender for their actions. Reviewed by me. --- AppKit/CPToolbar.j | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index d4a540a01..b2763b95c 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -799,10 +799,11 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) hasNonSeparatorItem = YES; - var menuItem = [[CPMenuItem alloc] initWithTitle:[item label] action:[item action] keyEquivalent:nil]; + var menuItem = [[CPMenuItem alloc] initWithTitle:[item label] action:@selector(didSelectMenuItem:) keyEquivalent:nil]; + [menuItem setRepresentedObject:item]; [menuItem setImage:[item image]]; - [menuItem setTarget:[item target]]; + [menuItem setTarget:self]; [menuItem setEnabled:[item isEnabled]]; [_additionalItemsButton addItem:menuItem]; @@ -812,6 +813,18 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) [_additionalItemsButton removeFromSuperview]; } +/* + Used privately. + @ignore +*/ + +- (void)didSelectMenuItem:(id)aSender +{ + var toolbarItem = [aSender representedObject]; + + [CPApp sendAction:[toolbarItem action] to:[toolbarItem target] from:toolbarItem]; +} + - (void)reloadToolbarItems { // Get rid of all our current subviews.