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.