aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-01-23 17:51:44 +0000
committerrowanbeentje <rowan@beent.je>2011-01-23 17:51:44 +0000
commitc3a96a5e8b260244d7deb6c99b419a38a53eb604 (patch)
treeacb21bdd3eb0309cfcb368d1d1a5d350e9c5f792 /Source
parent9fc507268a5158ae0045b753a288f2df6500e0c5 (diff)
downloadsequelpro-c3a96a5e8b260244d7deb6c99b419a38a53eb604.tar.gz
sequelpro-c3a96a5e8b260244d7deb6c99b419a38a53eb604.tar.bz2
sequelpro-c3a96a5e8b260244d7deb6c99b419a38a53eb604.zip
- Change shortcut for "Duplicate Connection Tab" to alt-T for increased discoverability - this improves on Issue #943
- Add alternate keybindings for tab switching - support command-shift-[ and -], and command-alt-left and right arrows to match behaviour of other applications - Update localisable strings
Diffstat (limited to 'Source')
-rw-r--r--Source/SPWindow.h32
-rw-r--r--Source/SPWindow.m80
2 files changed, 112 insertions, 0 deletions
diff --git a/Source/SPWindow.h b/Source/SPWindow.h
new file mode 100644
index 00000000..369ce769
--- /dev/null
+++ b/Source/SPWindow.h
@@ -0,0 +1,32 @@
+//
+// $Id$
+//
+// SPWindow.h
+// sequel-pro
+//
+// Created by Rowan Beentje on January 23, 2011
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// More info at <http://code.google.com/p/sequel-pro/>
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface SPWindow : NSWindow {
+
+}
+
+@end
diff --git a/Source/SPWindow.m b/Source/SPWindow.m
new file mode 100644
index 00000000..22f4f4ba
--- /dev/null
+++ b/Source/SPWindow.m
@@ -0,0 +1,80 @@
+//
+// $Id$
+//
+// SPWindow.m
+// sequel-pro
+//
+// Created by Rowan Beentje on January 23, 2011
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// More info at <http://code.google.com/p/sequel-pro/>
+
+#import "SPWindow.h"
+
+
+@implementation SPWindow
+
+#pragma mark -
+#pragma mark Keyboard shortcut additions
+
+/**
+ * While keyboard shortcuts are an easy way to apply code app-wide, alternate menu
+ * items only collapse if the unmodified key matches; this method allows keyboard
+ * shortcuts without menu equivalents for a window, or the use of different base shortcuts.
+ */
+- (void) sendEvent:(NSEvent *)theEvent
+{
+ if ([theEvent type] == NSKeyDown) {
+ unichar theCharacter = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
+
+ switch (theCharacter) {
+
+ // Alternate keys for switching tabs - ⇧⌘[ and ⇧⌘]. These seem to be standards on some apps,
+ // including Apple applications under some circumstances
+ case '}':
+ if (([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == (NSCommandKeyMask | NSShiftKeyMask))
+ {
+ return [[self windowController] selectNextDocumentTab:self];
+ }
+ break;
+ case '{':
+ if (([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == (NSCommandKeyMask | NSShiftKeyMask))
+ {
+ return [[self windowController] selectPreviousDocumentTab:self];
+ }
+ break;
+
+ // Also support ⌥⌘← and ⌥⌘→, used in other applications, for maximum compatibility
+ case NSRightArrowFunctionKey:
+ if (([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == (NSCommandKeyMask | NSAlternateKeyMask | NSNumericPadKeyMask | NSFunctionKeyMask))
+ {
+ return [[self windowController] selectNextDocumentTab:self];
+ }
+ break;
+ case NSLeftArrowFunctionKey:
+ if (([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == (NSCommandKeyMask | NSAlternateKeyMask | NSNumericPadKeyMask | NSFunctionKeyMask))
+ {
+ return [[self windowController] selectPreviousDocumentTab:self];
+ }
+ break;
+ }
+ }
+
+ [super sendEvent:theEvent];
+}
+
+
+@end