Permalink
Browse files

Fix bundle commands no longer working in popup field editor (and poss…

…ibly other cases) (#2299)

Replacing some [NSApp mainWindow] with their actually intended calls [NSApp keyWindow] and [view window]
  • Loading branch information...
dmoagx committed Oct 20, 2015
1 parent 5357fd1 commit ffbf7a4a9d4c617afd47a5428a17e0646b9bce97
View
@@ -2024,7 +2024,7 @@ - (IBAction)bundleCommandDispatcher:(id)sender
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 @@ - (IBAction)bundleCommandDispatcher:(id)sender
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 @@ - (IBAction)bundleCommandDispatcher:(id)sender
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 {
@@ -1334,7 +1334,7 @@ - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBy
//abort editing
[control abortEditing];
[[NSApp mainWindow] makeFirstResponder:commandsOutlineView];
[[commandsOutlineView window] makeFirstResponder:commandsOutlineView];
return YES;
} else{
return NO;
@@ -1452,7 +1452,7 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
(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]);
}
View
@@ -2583,16 +2583,17 @@ - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
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];
}
}
}
@@ -5291,8 +5291,9 @@ - (void)handleSchemeCommand:(NSDictionary*)commandDict
}
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 @@ - (void)_processDatabaseChangedBundleTriggerActions
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];
}
}
}
@@ -615,16 +615,17 @@ - (void)_loadTableTask
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];
}
}
}
@@ -148,18 +148,18 @@ - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
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];
}
}
}
View
@@ -30,7 +30,7 @@
@interface SPTableInfo : NSObject
{
IBOutlet id infoTable;
IBOutlet NSTableView *infoTable;
IBOutlet id tableList;
IBOutlet id tableListInstance;
IBOutlet id tableDataInstance;
View
@@ -390,11 +390,11 @@ - (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn
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];
View
@@ -1634,7 +1634,7 @@ - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBy
[textView methodForSelector:command] == [textView methodForSelector:@selector(complete:)] ) {
[control abortEditing];
[[NSApp mainWindow] makeFirstResponder:tablesListView];
[[tablesListView window] makeFirstResponder:tablesListView];
return YES;
} else{
@@ -183,7 +183,7 @@ - (NSCellHitResult) hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame of
// 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 @@ - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *
// 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];
@@ -849,7 +849,7 @@ - (NSMenu *)menuForEvent:(NSEvent *)event
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]];

0 comments on commit ffbf7a4

Please sign in to comment.