Fixed toolbar to work in text only mode

This commit is contained in:
michael starke
2013-06-08 19:05:59 +02:00
parent 850835239a
commit a014f2925c
2 changed files with 15 additions and 8 deletions

View File

@@ -56,8 +56,8 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR";
NSToolbarItem *item = self.toolbarItems[itemIdentifier]; NSToolbarItem *item = self.toolbarItems[itemIdentifier];
if(!item) { if(!item) {
item = [[MPToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; item = [[MPToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
NSString *label = [self _localizedLabelForToolbarItemIdentifier:itemIdentifier]; NSString *itemLabel = [self _localizedLabelForToolbarItemIdentifier:itemIdentifier];
[item setLabel:label]; [item setLabel:itemLabel];
if([itemIdentifier isEqualToString:MPToolbarItemAction]) { if([itemIdentifier isEqualToString:MPToolbarItemAction]) {
NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 32) pullsDown:YES]; NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 32) pullsDown:YES];
@@ -68,9 +68,7 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR";
NSRect newFrame = [popupButton frame]; NSRect newFrame = [popupButton frame];
newFrame.size.width += 20; newFrame.size.width += 20;
NSMenu *menu = [[NSMenu allocWithZone:[NSMenu menuZone]] init]; NSMenu *menu = [[NSMenu allocWithZone:[NSMenu menuZone]] init];
NSMenuItem *actionImageItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"" action:NULL keyEquivalent:@""]; NSMenuItem *actionImageItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:@"" action:NULL keyEquivalent:@""];
[actionImageItem setImage:self.toolbarImages[MPToolbarItemAction]]; [actionImageItem setImage:self.toolbarImages[MPToolbarItemAction]];
@@ -80,12 +78,17 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR";
for(NSMenuItem *item in menuItems) { for(NSMenuItem *item in menuItems) {
[menu addItem:item]; [menu addItem:item];
} }
NSMenuItem *menuRepresentation = [[NSMenuItem alloc] initWithTitle:itemLabel
action:[self _actionForToolbarItemIdentifier:itemIdentifier]
keyEquivalent:@""];
[menuRepresentation setSubmenu:menu];
[popupButton setFrame:newFrame]; [popupButton setFrame:newFrame];
[popupButton setMenu:menu]; [popupButton setMenu:menu];
[menu release]; [item setMenuFormRepresentation:menuRepresentation];
[item setView:popupButton]; [item setView:popupButton];
[popupButton release]; [popupButton release];
[menu release];
} }
else { else {
NSButton *button = [[MPToolbarButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)]; NSButton *button = [[MPToolbarButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)];
@@ -104,6 +107,10 @@ NSString *const MPToolbarItemInspector = @"TOOLBAR_INSPECTOR";
fittingRect.size.width = MAX( (CGFloat)32.0,fittingRect.size.width); fittingRect.size.width = MAX( (CGFloat)32.0,fittingRect.size.width);
[button setFrame:fittingRect]; [button setFrame:fittingRect];
[item setView:button]; [item setView:button];
NSMenuItem *menuRepresentation = [[NSMenuItem alloc] initWithTitle:itemLabel
action:[self _actionForToolbarItemIdentifier:itemIdentifier]
keyEquivalent:@""];
[item setMenuFormRepresentation:menuRepresentation];
[button release]; [button release];
} }
self.toolbarItems[itemIdentifier] = item; self.toolbarItems[itemIdentifier] = item;

View File

@@ -48,7 +48,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>972</string> <string>979</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string> <string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>