From 4dfa685461faec53e709afaba1323c8384d1c412 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 8 May 2011 00:37:16 +0000 Subject: Add tab context menu. --- Source/SPWindowController.m | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index e9b73491..c097e711 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -160,14 +160,14 @@ */ - (IBAction) closeTab:(id)sender { - // Return if the selected tab shouldn't be closed if (![selectedTableDocument parentTabShouldClose]) return; // If there are multiple tabs, close the front tab. if ([tabView numberOfTabViewItems] > 1) { [tabView removeTabViewItem:[tabView selectedTabViewItem]]; - } else { + } + else { [[self window] performClose:self]; } } @@ -571,6 +571,20 @@ return [viewImage autorelease]; } +/** + * Displays the current tab's context menu. + */ +- (NSMenu *)tabView:(NSTabView *)aTabView menuForTabViewItem:(NSTabViewItem *)tabViewItem +{ + NSMenu *menu = [[NSMenu alloc] init]; + + [menu addItemWithTitle:NSLocalizedString(@"Close Tab", @"close tab context menu item") action:@selector(closeTab:) keyEquivalent:@""]; + [menu insertItem:[NSMenuItem separatorItem] atIndex:1]; + [menu addItemWithTitle:NSLocalizedString(@"Open in New Tab", @"open connection in new tab context menu item") action:@selector(openDatabaseInNewTab:) keyEquivalent:@""]; + + return [menu autorelease]; +} + /** * When tab drags start, show all the tab bars. This allows adding tabs to windows * containing only one tab - where the bar is normally hidden. -- cgit v1.2.3