From a7247b9f9098b40f170f6b2bcd28a4e934a02dc5 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 11 Jun 2010 11:57:54 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Select=20Next/Previous=20Tab=20now=20cycles?= =?UTF-8?q?=20through=20available=20tabs=20if=20it's=20called=20for=20the?= =?UTF-8?q?=20last/first=20tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPWindowController.m | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'Source') diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index b68a4668..a19bcd08 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -152,19 +152,25 @@ } /** - * Select next tab. + * Select next tab; if last select first one. */ - (IBAction)selectNextDocumentTab:(id)sender { - [tabView selectNextTabViewItem:nil]; + if([tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == [tabView numberOfTabViewItems] - 1) + [tabView selectFirstTabViewItem:nil]; + else + [tabView selectNextTabViewItem:nil]; } /** - * Select previous tab. + * Select previous tab; if first select last one. */ - (IBAction)selectPreviousDocumentTab:(id)sender { - [tabView selectPreviousTabViewItem:nil]; + if([tabView indexOfTabViewItem:[tabView selectedTabViewItem]] == 0) + [tabView selectLastTabViewItem:nil]; + else + [tabView selectPreviousTabViewItem:nil]; } /** @@ -172,16 +178,11 @@ */ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - // Select Previous Tab - if ([menuItem action] == @selector(selectPreviousDocumentTab:)) { - return ([tabView numberOfTabViewItems] && [tabView indexOfTabViewItem:[tabView selectedTabViewItem]]); + // Select Next/Previous Tab + if ([menuItem action] == @selector(selectPreviousDocumentTab:) || [menuItem action] == @selector(selectNextDocumentTab:)) { + return ([tabView numberOfTabViewItems] != 1); } - - // Select Next Tab - if ([menuItem action] == @selector(selectNextDocumentTab:)) { - return ([tabView numberOfTabViewItems] && [tabView indexOfTabViewItem:[tabView selectedTabViewItem]]<[tabView numberOfTabViewItems]-1); - } - + return YES; } -- cgit v1.2.3