From fb96c4b17accaab40f972bef05f421fe85cb1fdb Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 11 Jun 2010 11:32:43 +0000 Subject: =?UTF-8?q?=E2=80=A2=20add=20to=20Main=20Menu=20>=20View=20>=20:?= =?UTF-8?q?=20-=20Select=20Next=20Tab=20^=E2=87=A5=20-=20Select=20Previous?= =?UTF-8?q?=20^=E2=87=A7=E2=87=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and menu validation to be able to navigate through available tabs by using the keyboard. --- Source/SPWindowController.h | 2 ++ Source/SPWindowController.m | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) (limited to 'Source') diff --git a/Source/SPWindowController.h b/Source/SPWindowController.h index d46deb19..49c85acc 100644 --- a/Source/SPWindowController.h +++ b/Source/SPWindowController.h @@ -41,6 +41,8 @@ - (SPDatabaseDocument *) selectedTableDocument; - (void) updateAllTabTitles:(id)sender; - (IBAction)closeTab:(id)sender; +- (IBAction)selectNextDocumentTab:(id)sender; +- (IBAction)selectPreviousDocumentTab:(id)sender; - (NSArray *)documents; @end diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index c6400c96..b68a4668 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -151,6 +151,40 @@ } } +/** + * Select next tab. + */ +- (IBAction)selectNextDocumentTab:(id)sender +{ + [tabView selectNextTabViewItem:nil]; +} + +/** + * Select previous tab. + */ +- (IBAction)selectPreviousDocumentTab:(id)sender +{ + [tabView selectPreviousTabViewItem:nil]; +} + +/** + * Menu validation + */ +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + // Select Previous Tab + if ([menuItem action] == @selector(selectPreviousDocumentTab:)) { + return ([tabView numberOfTabViewItems] && [tabView indexOfTabViewItem:[tabView selectedTabViewItem]]); + } + + // Select Next Tab + if ([menuItem action] == @selector(selectNextDocumentTab:)) { + return ([tabView numberOfTabViewItems] && [tabView indexOfTabViewItem:[tabView selectedTabViewItem]]<[tabView numberOfTabViewItems]-1); + } + + return YES; +} + /** * Retrieve the documents associated with this window. */ @@ -241,6 +275,15 @@ } } +/** + * Show tooltip for a tab view item. + */ +- (NSString *)tabView:(NSTabView *)aTabView toolTipForTabViewItem:(NSTabViewItem *)tabViewItem +{ + // Not yet implemented + return @""; +} + - (void)tabView:(NSTabView *)aTabView closeWindowForLastTabViewItem:(NSTabViewItem *)tabViewItem { [[aTabView window] close]; -- cgit v1.2.3