aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-10-21 00:39:34 +0200
committerMax <post@wickenrode.com>2015-10-21 03:27:25 +0200
commitb089a0d3249d3139bedc2679a36efa705d2bae04 (patch)
treedf43a2984520b318f0b8c281d85f2defd72d3943
parent91abde0c94df8bd7f63bd4e5d062562b0827adbd (diff)
downloadsequelpro-b089a0d3249d3139bedc2679a36efa705d2bae04.tar.gz
sequelpro-b089a0d3249d3139bedc2679a36efa705d2bae04.tar.bz2
sequelpro-b089a0d3249d3139bedc2679a36efa705d2bae04.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 9ff2cad0..6489a76a 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -1966,7 +1966,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;
@@ -2018,7 +2018,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 {
@@ -2037,7 +2037,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 a6e14b34..9289f2ce 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -2563,16 +2563,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 898c19c3..05eec2ed 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -5259,8 +5259,9 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase";
}
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;
}
@@ -6262,17 +6263,18 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase";
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 ea2186cc..a1ec3e30 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 07c355b9..4d14180b 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 74523da3..4a57a174 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 56103a53..2e7d796d 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -843,7 +843,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]];