aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-10-21 00:39:34 +0200
committerMax <post@wickenrode.com>2015-10-21 00:39:34 +0200
commitffbf7a4a9d4c617afd47a5428a17e0646b9bce97 (patch)
tree9fe49434f160567671b1fe844b1fd590db1108af
parent5357fd1375d19a6c5de96293b3899f430422a3c0 (diff)
downloadsequelpro-ffbf7a4a9d4c617afd47a5428a17e0646b9bce97.tar.gz
sequelpro-ffbf7a4a9d4c617afd47a5428a17e0646b9bce97.tar.bz2
sequelpro-ffbf7a4a9d4c617afd47a5428a17e0646b9bce97.zip
Fix bundle commands no longer working in popup field editor (and possibly other cases) (#2299)
Replacing some [NSApp mainWindow] with their actually intended calls [NSApp keyWindow] and [view window]
-rw-r--r--Source/SPAppController.m6
-rw-r--r--Source/SPBundleEditorController.m4
-rw-r--r--Source/SPCustomQuery.m9
-rw-r--r--Source/SPDatabaseDocument.m14
-rw-r--r--Source/SPDatabaseViewController.m9
-rw-r--r--Source/SPTableContentDelegate.m10
-rw-r--r--Source/SPTableInfo.h2
-rw-r--r--Source/SPTableInfo.m4
-rw-r--r--Source/SPTablesList.m2
-rw-r--r--Source/SPTextAndLinkCell.m4
-rw-r--r--Source/SPTextViewAdditions.m2
11 files changed, 35 insertions, 31 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 7ed49859..91ce9737 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -2024,7 +2024,7 @@
NSEvent *event = [NSApp currentEvent];
BOOL checkForKeyEquivalents = ([event type] == NSKeyDown) ? YES : NO;
- id firstResponder = [[NSApp mainWindow] firstResponder];
+ id firstResponder = [[NSApp keyWindow] firstResponder];
NSString *scope = [[sender representedObject] objectForKey:@"scope"];
NSString *keyEqKey = nil;
@@ -2076,7 +2076,7 @@
NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
[aMenuItem setTag:0];
[aMenuItem setToolTip:[eq objectForKey:@"path"]];
- [(SPTextView *)[[NSApp mainWindow] firstResponder] executeBundleItemForInputField:aMenuItem];
+ [(SPTextView *)firstResponder executeBundleItemForInputField:aMenuItem];
}
}
} else {
@@ -2095,7 +2095,7 @@
NSMenuItem *aMenuItem = [[[NSMenuItem alloc] init] autorelease];
[aMenuItem setTag:0];
[aMenuItem setToolTip:[eq objectForKey:@"path"]];
- [(SPCopyTable *)[[NSApp mainWindow] firstResponder] executeBundleItemForDataTable:aMenuItem];
+ [(SPCopyTable *)firstResponder executeBundleItemForDataTable:aMenuItem];
}
}
} else {
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index a0c7d7ce..7757c0ba 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -1334,7 +1334,7 @@
//abort editing
[control abortEditing];
- [[NSApp mainWindow] makeFirstResponder:commandsOutlineView];
+ [[commandsOutlineView window] makeFirstResponder:commandsOutlineView];
return YES;
} else{
return NO;
@@ -1452,7 +1452,7 @@
(action == @selector(displayBundleMetaInfo:)))
{
// Allow to record short-cuts used by the Bundle Editor
- if([[NSApp mainWindow] firstResponder] == keyEquivalentField) return NO;
+ if([[NSApp keyWindow] firstResponder] == keyEquivalentField) return NO;
return ([[commandBundleTreeController selectedObjects] count] == 1 && ![[[commandBundleTreeController selectedObjects] objectAtIndex:0] objectForKey:kChildrenKey]);
}
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 7b446237..4737bea8 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -2583,16 +2583,17 @@
if(!correspondingWindowFound) stopTrigger = YES;
}
if(!stopTrigger) {
+ id firstResponder = [[NSApp keyWindow] firstResponder];
if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
[[SPAppDelegate onMainThread] executeBundleItemForApp:aMenuItem];
}
else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
- if([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+ if([[[firstResponder class] description] isEqualToString:@"SPCopyTable"])
+ [[firstResponder onMainThread] executeBundleItemForDataTable:aMenuItem];
}
else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
- if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ if([firstResponder isKindOfClass:[NSTextView class]])
+ [[firstResponder onMainThread] executeBundleItemForInputField:aMenuItem];
}
}
}
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index bd258662..fd4a74c5 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -5291,8 +5291,9 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
}
if([command isEqualToString:@"SelectTableRows"]) {
- if([params count] > 1 && [[[NSApp mainWindow] firstResponder] respondsToSelector:@selector(selectTableRows:)]) {
- [(SPCopyTable *)[[NSApp mainWindow] firstResponder] selectTableRows:[params subarrayWithRange:NSMakeRange(1, [params count]-1)]];
+ id firstResponder = [[NSApp keyWindow] firstResponder];
+ if([params count] > 1 && [firstResponder respondsToSelector:@selector(selectTableRows:)]) {
+ [(SPCopyTable *)firstResponder selectTableRows:[params subarrayWithRange:NSMakeRange(1, [params count]-1)]];
}
return;
}
@@ -6307,17 +6308,18 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
if(!correspondingWindowFound) stopTrigger = YES;
}
if(!stopTrigger) {
+ id firstResponder = [[NSApp keyWindow] firstResponder];
if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
[[SPAppDelegate onMainThread] executeBundleItemForApp:aMenuItem];
}
else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
- if ([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"]) {
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+ if ([[[firstResponder class] description] isEqualToString:@"SPCopyTable"]) {
+ [[firstResponder onMainThread] executeBundleItemForDataTable:aMenuItem];
}
}
else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
- if ([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]]) {
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ if ([firstResponder isKindOfClass:[NSTextView class]]) {
+ [[firstResponder onMainThread] executeBundleItemForInputField:aMenuItem];
}
}
}
diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m
index f0ee65d5..194ee3b4 100644
--- a/Source/SPDatabaseViewController.m
+++ b/Source/SPDatabaseViewController.m
@@ -615,16 +615,17 @@
if(!correspondingWindowFound) stopTrigger = YES;
}
if(!stopTrigger) {
+ id firstResponder = [[NSApp keyWindow] firstResponder];
if([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
[[SPAppDelegate onMainThread] executeBundleItemForApp:aMenuItem];
}
else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
- if([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+ if([[[firstResponder class] description] isEqualToString:@"SPCopyTable"])
+ [[firstResponder onMainThread] executeBundleItemForDataTable:aMenuItem];
}
else if([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
- if([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]])
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ if([firstResponder isKindOfClass:[NSTextView class]])
+ [[firstResponder onMainThread] executeBundleItemForInputField:aMenuItem];
}
}
}
diff --git a/Source/SPTableContentDelegate.m b/Source/SPTableContentDelegate.m
index eee0fb0a..bf7aac5d 100644
--- a/Source/SPTableContentDelegate.m
+++ b/Source/SPTableContentDelegate.m
@@ -148,18 +148,18 @@
if (!correspondingWindowFound) stopTrigger = YES;
}
if (!stopTrigger) {
-
+ id firstResponder = [[NSApp keyWindow] firstResponder];
if ([[data objectAtIndex:1] isEqualToString:SPBundleScopeGeneral]) {
[[SPAppDelegate onMainThread] executeBundleItemForApp:aMenuItem];
}
else if ([[data objectAtIndex:1] isEqualToString:SPBundleScopeDataTable]) {
- if ([[[[[NSApp mainWindow] firstResponder] class] description] isEqualToString:@"SPCopyTable"]) {
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForDataTable:aMenuItem];
+ if ([[[firstResponder class] description] isEqualToString:@"SPCopyTable"]) {
+ [[firstResponder onMainThread] executeBundleItemForDataTable:aMenuItem];
}
}
else if ([[data objectAtIndex:1] isEqualToString:SPBundleScopeInputField]) {
- if ([[[NSApp mainWindow] firstResponder] isKindOfClass:[NSTextView class]]) {
- [[[[NSApp mainWindow] firstResponder] onMainThread] executeBundleItemForInputField:aMenuItem];
+ if ([firstResponder isKindOfClass:[NSTextView class]]) {
+ [[firstResponder onMainThread] executeBundleItemForInputField:aMenuItem];
}
}
}
diff --git a/Source/SPTableInfo.h b/Source/SPTableInfo.h
index 56b22077..13a72976 100644
--- a/Source/SPTableInfo.h
+++ b/Source/SPTableInfo.h
@@ -30,7 +30,7 @@
@interface SPTableInfo : NSObject
{
- IBOutlet id infoTable;
+ IBOutlet NSTableView *infoTable;
IBOutlet id tableList;
IBOutlet id tableListInstance;
IBOutlet id tableDataInstance;
diff --git a/Source/SPTableInfo.m b/Source/SPTableInfo.m
index e1ce3e4d..8268662b 100644
--- a/Source/SPTableInfo.m
+++ b/Source/SPTableInfo.m
@@ -390,11 +390,11 @@
if (![tableInfoScrollView isHidden]) {
[tableDocumentInstance setActivityPaneHidden:@0];
- [[NSApp mainWindow] makeFirstResponder:activitiesTable];
+ [[activitiesTable window] makeFirstResponder:activitiesTable];
}
else {
[tableDocumentInstance setActivityPaneHidden:@1];
- [[NSApp mainWindow] makeFirstResponder:infoTable];
+ [[infoTable window] makeFirstResponder:infoTable];
}
[infoTable deselectAll:nil];
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m
index 76671530..4189d618 100644
--- a/Source/SPTablesList.m
+++ b/Source/SPTablesList.m
@@ -1634,7 +1634,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable";
[textView methodForSelector:command] == [textView methodForSelector:@selector(complete:)] ) {
[control abortEditing];
- [[NSApp mainWindow] makeFirstResponder:tablesListView];
+ [[tablesListView window] makeFirstResponder:tablesListView];
return YES;
} else{
diff --git a/Source/SPTextAndLinkCell.m b/Source/SPTextAndLinkCell.m
index 2aefbff5..9759903d 100644
--- a/Source/SPTextAndLinkCell.m
+++ b/Source/SPTextAndLinkCell.m
@@ -183,7 +183,7 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect)
// Fast case for no link - make entire cell editable click area
if (!hasLink || !linkActive) return NSCellHitContentArea | NSCellHitEditableTextArea;
- NSPoint p = [[[NSApp mainWindow] contentView] convertPoint:[event locationInWindow] toView:controlView];
+ NSPoint p = [[[controlView window] contentView] convertPoint:[event locationInWindow] toView:controlView];
NSRect linkRect = SPTextLinkRectFromCellRect(cellFrame);
// Hit the link if it falls within the link rectangle for this cell, set when drawing
@@ -233,7 +233,7 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect)
// Capture the clicked row and cell
NSTableView *tableView = (NSTableView *)[self controlView];
- p = [[[NSApp mainWindow] contentView] convertPoint:[theEvent locationInWindow] toView:tableView];
+ p = [[[tableView window] contentView] convertPoint:[theEvent locationInWindow] toView:tableView];
lastLinkColumn = [tableView columnAtPoint:p];
lastLinkRow = [tableView rowAtPoint:p];
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index ef5c776e..88096a8f 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -849,7 +849,7 @@
if([keyEq length])
[mItem setKeyEquivalentModifierMask:[[[item objectForKey:SPBundleFileKeyEquivalentKey] objectAtIndex:1] intValue]];
- [mItem setTarget:[[NSApp mainWindow] firstResponder]];
+ [mItem setTarget:[[NSApp keyWindow] firstResponder]];
if([item objectForKey:SPBundleFileTooltipKey])
[mItem setToolTip:[item objectForKey:SPBundleFileTooltipKey]];