aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPWindow.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2011-01-26 11:27:50 +0000
committerBibiko <bibiko@eva.mpg.de>2011-01-26 11:27:50 +0000
commit7cc062247ff23496dd0390cf07b5d45d6bc49777 (patch)
tree8c9563f96e0015ce5fdc4c73190cbaf736fd1e93 /Source/SPWindow.m
parent03573a327829b79ce13de972b32a4a7fef12e04b (diff)
downloadsequelpro-7cc062247ff23496dd0390cf07b5d45d6bc49777.tar.gz
sequelpro-7cc062247ff23496dd0390cf07b5d45d6bc49777.tar.bz2
sequelpro-7cc062247ff23496dd0390cf07b5d45d6bc49777.zip
• bound short-cut ⌥⎋ to display the context menu of the first responder if responder is embedded in a SPWindow
Diffstat (limited to 'Source/SPWindow.m')
-rw-r--r--Source/SPWindow.m31
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/SPWindow.m b/Source/SPWindow.m
index 69d3e4a5..58f38d0b 100644
--- a/Source/SPWindow.m
+++ b/Source/SPWindow.m
@@ -37,10 +37,41 @@
*/
- (void) sendEvent:(NSEvent *)theEvent
{
+
if ([theEvent type] == NSKeyDown && [[theEvent characters] length]) {
unichar theCharacter = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
+ // ⌃⎋ sends a right-click to order front the context menu under the first responder's visible Rect
+ if ([theEvent keyCode] == 53 && (([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == (NSAlternateKeyMask))) {
+
+ id firstResponder = [[NSApp keyWindow] firstResponder];
+
+ if(firstResponder && [firstResponder respondsToSelector:@selector(menuForEvent:)]) {
+
+ NSRect theRect = [firstResponder visibleRect];
+ NSPoint loc = theRect.origin;
+ loc.y += theRect.size.height+5;
+ loc = [firstResponder convertPoint:loc toView:nil];
+ NSEvent *anEvent = [NSEvent
+ mouseEventWithType:NSRightMouseDown
+ location:loc
+ modifierFlags:0
+ timestamp:1
+ windowNumber:[self windowNumber]
+ context:[NSGraphicsContext currentContext]
+ eventNumber:0
+ clickCount:1
+ pressure:0.0];
+
+ [NSMenu popUpContextMenu:[firstResponder menuForEvent:theEvent] withEvent:anEvent forView:firstResponder];
+
+ return;
+
+ }
+
+ }
+
switch (theCharacter) {
// Alternate keys for switching tabs - ⇧⌘[ and ⇧⌘]. These seem to be standards on some apps,