aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-12-03 12:32:35 +0000
committerBibiko <bibiko@eva.mpg.de>2010-12-03 12:32:35 +0000
commit5c941dbdd8fb13c0938f03cc7902fa6d7a8a740d (patch)
tree543ec6d154821fc88fd1f17afe5969182f87e374
parent81007b19f8df9efd7a3fd3999d29ddb2af006125 (diff)
downloadsequelpro-5c941dbdd8fb13c0938f03cc7902fa6d7a8a740d.tar.gz
sequelpro-5c941dbdd8fb13c0938f03cc7902fa6d7a8a740d.tar.bz2
sequelpro-5c941dbdd8fb13c0938f03cc7902fa6d7a8a740d.zip
• preparations for handling issue if user assigned the same keyboard short-cut on different Bundle commands; if so show a kind of a context menu to pick up one item; this will be done via the new SPChooseMenuItem class which will display a borderless window with a context menu at a passed location
-rw-r--r--Source/SPAppController.m53
-rw-r--r--Source/SPChooseMenuItemDialog.h34
-rw-r--r--Source/SPChooseMenuItemDialog.m30
-rw-r--r--sequel-pro.xcodeproj/project.pbxproj6
4 files changed, 116 insertions, 7 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 2ff780ae..89a6359c 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -36,6 +36,7 @@
#import "SPTooltip.h"
#import "SPBundleHTMLOutputController.h"
#import "SPAlertSheets.h"
+#import "SPChooseMenuItemDialog.h"
#import <PSMTabBar/PSMTabBarControl.h>
#import <Sparkle/Sparkle.h>
@@ -1275,9 +1276,12 @@
mask = mask | NSAlternateKeyMask;
if([theMods rangeOfString:@"$"].length)
mask = mask | NSShiftKeyMask;
- for(NSString* scope in scopes)
- [[bundleKeyEquivalents objectForKey:scope] setObject:[NSArray arrayWithObjects:[theChar lowercaseString],
- [NSNumber numberWithInteger:mask], infoPath, nil] forKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]];
+ for(NSString* scope in scopes) {
+ if(![[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]])
+ [[bundleKeyEquivalents objectForKey:scope] setObject:[NSMutableArray array] forKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]];
+ [[[bundleKeyEquivalents objectForKey:scope] objectForKey:[cmdData objectForKey:SPBundleFileKeyEquivalentKey]] addObject:
+ [NSArray arrayWithObjects:[theChar lowercaseString], [NSNumber numberWithInteger:mask], infoPath, [cmdData objectForKey:SPBundleFileNameKey], nil]];
+ }
[aDict setObject:[NSArray arrayWithObjects:theChar, [NSNumber numberWithInteger:mask], nil] forKey:SPBundleInternKeyEquivalentKey];
}
@@ -1444,6 +1448,7 @@
{
NSDictionary *keyEqsGeneral = [bundleKeyEquivalents objectForKey:SPBundleScopeGeneral];
NSDictionary *keyEqsDataTable = [bundleKeyEquivalents objectForKey:SPBundleScopeDataTable];
+ NSDictionary *keyEqsInputFields = [bundleKeyEquivalents objectForKey:SPBundleScopeInputField];
while(!stopKeyDownListener) {
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
@@ -1461,8 +1466,12 @@
long curFlags = ([event modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask));
BOOL found = NO;
for(NSString *eqs in [keyEqsGeneral allKeys]) {
- NSArray *eq = [keyEqsGeneral objectForKey:eqs];
- if([NSArrayObjectAtIndex(eq,0) isEqualToString:charactersIgnMod] && [NSArrayObjectAtIndex(eq,1) intValue] == curFlags) {
+ NSInteger idx = 0;
+ if([[keyEqsInputFields objectForKey:eqs] count] > 1) {
+ // TODO
+ }
+ NSArray *eq = [[keyEqsDataTable objectForKey:eqs] objectAtIndex:idx];
+ if(eq && [eq count] && [NSArrayObjectAtIndex(eq,0) isEqualToString:charactersIgnMod] && [NSArrayObjectAtIndex(eq,1) intValue] == curFlags) {
NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
[aMenuItem setTag:0];
[aMenuItem setToolTip:[eq objectAtIndex:2]];
@@ -1483,8 +1492,12 @@
long curFlags = ([event modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask));
BOOL found = NO;
for(NSString *eqs in [keyEqsDataTable allKeys]) {
- NSArray *eq = [keyEqsDataTable objectForKey:eqs];
- if([NSArrayObjectAtIndex(eq,0) isEqualToString:charactersIgnMod] && [NSArrayObjectAtIndex(eq,1) intValue] == curFlags) {
+ NSInteger idx = 0;
+ if([[keyEqsInputFields objectForKey:eqs] count] > 1) {
+ // TODO
+ }
+ NSArray *eq = [[keyEqsDataTable objectForKey:eqs] objectAtIndex:idx];
+ if(eq && [eq count] && [NSArrayObjectAtIndex(eq,0) isEqualToString:charactersIgnMod] && [NSArrayObjectAtIndex(eq,1) intValue] == curFlags) {
NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
[aMenuItem setTag:0];
[aMenuItem setToolTip:[eq objectAtIndex:2]];
@@ -1496,6 +1509,32 @@
if(!found)
[NSApp sendEvent:event];
}
+ else if ([event type] == NSKeyDown
+ && ![[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SRRecorderControl"]
+ && [[[NSApp mainWindow] firstResponder] respondsToSelector:@selector(executeBundleItemForInputField:)]
+ ) {
+ // Check Bundle key equivalents due to same equivalents for Data Table scope
+ NSString *charactersIgnMod = [event charactersIgnoringModifiers];
+ long curFlags = ([event modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask));
+ BOOL found = NO;
+ for(NSString *eqs in [keyEqsInputFields allKeys]) {
+ NSInteger idx = 0;
+ if([[keyEqsInputFields objectForKey:eqs] count] > 1) {
+ // TODO
+ }
+ NSArray *eq = [[keyEqsInputFields objectForKey:eqs] objectAtIndex:idx];
+ if(eq && [eq count] && [NSArrayObjectAtIndex(eq,0) isEqualToString:charactersIgnMod] && [NSArrayObjectAtIndex(eq,1) intValue] == curFlags) {
+ NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
+ [aMenuItem setTag:0];
+ [aMenuItem setToolTip:[eq objectAtIndex:2]];
+ [[[NSApp mainWindow] firstResponder] executeBundleItemForInputField:aMenuItem];
+ found = YES;
+ break;
+ }
+ }
+ if(!found)
+ [NSApp sendEvent:event];
+ }
else {
[NSApp sendEvent:event];
}
diff --git a/Source/SPChooseMenuItemDialog.h b/Source/SPChooseMenuItemDialog.h
new file mode 100644
index 00000000..4b6f4a67
--- /dev/null
+++ b/Source/SPChooseMenuItemDialog.h
@@ -0,0 +1,34 @@
+//
+// $Id: SPChooseMenuItemDialog.h 744 2009-05-22 20:00:00Z bibiko $
+//
+// SPChooseMenuItemDialog.h
+// sequel-pro
+//
+// Created by Hans-J. Bibiko on Dec 03, 2010.
+//
+// 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 SPChooseMenuItemDialog : NSWindow
+
+{
+
+}
+
+@end
diff --git a/Source/SPChooseMenuItemDialog.m b/Source/SPChooseMenuItemDialog.m
new file mode 100644
index 00000000..2dc73077
--- /dev/null
+++ b/Source/SPChooseMenuItemDialog.m
@@ -0,0 +1,30 @@
+//
+// $Id: SPChooseMenuItemDialog.m 744 2009-05-22 20:00:00Z bibiko $
+//
+// SPChooseMenuItemDialog.m
+// sequel-pro
+//
+// Created by Hans-J. Bibiko on Dec 03, 2010.
+//
+// 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 "SPChooseMenuItemDialog.h"
+
+
+@implementation SPChooseMenuItemDialog
+
+@end
diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj
index 04fc6aab..be4a2f1a 100644
--- a/sequel-pro.xcodeproj/project.pbxproj
+++ b/sequel-pro.xcodeproj/project.pbxproj
@@ -388,6 +388,7 @@
BC0E1493120AABE900E52E25 /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 17B7B58F1016028F00F057DE /* libcrypto.dylib */; };
BC0E14A1120AAC2E00E52E25 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 179ECEC611F265EE009C6A40 /* libbz2.dylib */; };
BC0E14A4120AAC5000E52E25 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 583CE52C11725642008F148E /* libz.dylib */; };
+ BC0ED3DA12A9196C00088461 /* SPChooseMenuItemDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = BC0ED3D912A9196C00088461 /* SPChooseMenuItemDialog.m */; };
BC1847EA0FE6EC8400094BFB /* SPEditSheetTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = BC1847E90FE6EC8400094BFB /* SPEditSheetTextView.m */; };
BC1944D01297291800A236CD /* SPBundleCommandTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = BC1944CF1297291800A236CD /* SPBundleCommandTextView.m */; };
BC1E55C4100DC92200AAE9F0 /* table-view-small-square.tiff in Resources */ = {isa = PBXBuildFile; fileRef = BC1E55C3100DC92200AAE9F0 /* table-view-small-square.tiff */; };
@@ -1111,6 +1112,8 @@
BC09D7DB12A786FB0030DB64 /* cancel-hovered-highlighted.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "cancel-hovered-highlighted.png"; sourceTree = "<group>"; };
BC09D7DC12A786FB0030DB64 /* cancel-hovered.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "cancel-hovered.png"; sourceTree = "<group>"; };
BC09D7DD12A786FB0030DB64 /* cancel.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cancel.png; sourceTree = "<group>"; };
+ BC0ED3D812A9196C00088461 /* SPChooseMenuItemDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPChooseMenuItemDialog.h; sourceTree = "<group>"; };
+ BC0ED3D912A9196C00088461 /* SPChooseMenuItemDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPChooseMenuItemDialog.m; sourceTree = "<group>"; };
BC1847E80FE6EC8400094BFB /* SPEditSheetTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPEditSheetTextView.h; sourceTree = "<group>"; };
BC1847E90FE6EC8400094BFB /* SPEditSheetTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPEditSheetTextView.m; sourceTree = "<group>"; };
BC1944CE1297291800A236CD /* SPBundleCommandTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPBundleCommandTextView.h; sourceTree = "<group>"; };
@@ -1971,6 +1974,8 @@
172A65100F7BED7A001E861A /* SPConsoleMessage.m */,
17C058860FC9FC390077E9CF /* SPNarrowDownCompletion.h */,
17C058870FC9FC390077E9CF /* SPNarrowDownCompletion.m */,
+ BC0ED3D812A9196C00088461 /* SPChooseMenuItemDialog.h */,
+ BC0ED3D912A9196C00088461 /* SPChooseMenuItemDialog.m */,
173E70A1107FF495008733C9 /* Core Data */,
);
name = Model;
@@ -3153,6 +3158,7 @@
BC77C5E4129AA69E009AD832 /* SPBundleHTMLOutputController.m in Sources */,
58DC10D312A1B8DF00B76DA5 /* SPMenuAdditions.m in Sources */,
BC5750D512A6233900911BA2 /* SPActivityTextFieldCell.m in Sources */,
+ BC0ED3DA12A9196C00088461 /* SPChooseMenuItemDialog.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};