From 53da62f33de2b7d3c28590ef87f3207570c5002c Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Sat, 9 May 2020 14:15:02 +0700 Subject: [PATCH] =?UTF-8?q?Fix=20issue=20with=20=E2=8C=98F=20not=20bringin?= =?UTF-8?q?g=20find=20dialog=20to=20active=20space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The problem is that we use ⌘F and ⇧⌘F as key equivalents both in the Edit → Find submenu and in the “where” pop-up button’s menu, but as they previously had different action methods, the system would only allow the key to trigger one of these items (and remove the key from the other, as part of menu validation). Normally not an issue, but when the find dialog is in another space, it appears menu validation would not update the Find → Edit submenu items to get the key equivalents, even though these would be “first responders”. By using same action method for both Find → Edit submenu items and the “where” pop-up menu items, we avoid the key equivalents being removed from any of the two menus. --- Frameworks/Find/src/Find.mm | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/Frameworks/Find/src/Find.mm b/Frameworks/Find/src/Find.mm index 15e7c4b4..d22a7f46 100644 --- a/Frameworks/Find/src/Find.mm +++ b/Frameworks/Find/src/Find.mm @@ -574,15 +574,15 @@ static NSButton* OakCreateHistoryButton (NSString* toolTip) NSMenuItem* folderItem; MBMenu const items = { - { @"Document", @selector(takeSearchTargetFrom:), @"f", .tag = FFSearchTargetDocument }, - { @"Selection", @selector(takeSearchTargetFrom:), .tag = FFSearchTargetSelection }, + { @"Document", @selector(orderFrontFindPanel:), @"f", .tag = FFSearchTargetDocument }, + { @"Selection", @selector(orderFrontFindPanel:), .tag = FFSearchTargetSelection }, { /* -------- */ }, - { @"Open Files", @selector(takeSearchTargetFrom:), .tag = FFSearchTargetOpenFiles }, - { @"Project Folder", @selector(takeSearchTargetFrom:), @"F", .tag = FFSearchTargetProject }, - { @"File Browser Items", @selector(takeSearchTargetFrom:), .tag = FFSearchTargetFileBrowserItems }, + { @"Open Files", @selector(orderFrontFindPanel:), .tag = FFSearchTargetOpenFiles }, + { @"Project Folder", @selector(orderFrontFindPanel:), @"F", .tag = FFSearchTargetProject }, + { @"File Browser Items", @selector(orderFrontFindPanel:), .tag = FFSearchTargetFileBrowserItems }, { @"Other Folder…", @selector(showFolderSelectionPanel:), .tag = FFSearchTargetOther }, { /* -------- */ }, - { @"«Last Folder»", @selector(takeSearchTargetFrom:), .ref = &folderItem }, + { @"«Last Folder»", @selector(orderFrontFindPanel:), .ref = &folderItem }, { /* -------- */ }, { @"Recent Places", @selector(nop:), }, }; @@ -627,7 +627,7 @@ static NSButton* OakCreateHistoryButton (NSString* toolTip) NSString* path = recentPaths[i]; - NSMenuItem* recentItem = [whereMenu addItemWithTitle:[self displayNameForFolder:path] action:@selector(takeSearchTargetFrom:) keyEquivalent:@""]; + NSMenuItem* recentItem = [whereMenu addItemWithTitle:[self displayNameForFolder:path] action:@selector(orderFrontFindPanel:) keyEquivalent:@""]; [recentItem setIconForFile:path]; [recentItem setRepresentedObject:path]; @@ -662,17 +662,20 @@ static NSButton* OakCreateHistoryButton (NSString* toolTip) self.showsResultsOutlineView = isFolderSearch; } -- (void)takeSearchTargetFrom:(NSMenuItem*)menuItem +- (void)orderFrontFindPanel:(id)sender { - if(NSString* folder = menuItem.representedObject) + if([sender respondsToSelector:@selector(representedObject)]) { - self.otherFolder = folder; - self.searchTarget = FFSearchTargetOther; - } - else - { - self.searchTarget = FFSearchTarget(menuItem.tag); + if(NSString* folder = [sender representedObject]) + { + self.otherFolder = folder; + self.searchTarget = FFSearchTargetOther; + return; + } } + + if([sender respondsToSelector:@selector(tag)]) + self.searchTarget = FFSearchTarget([sender tag]); } // ============================== @@ -854,14 +857,14 @@ static NSButton* OakCreateHistoryButton (NSString* toolTip) { NSInteger index = [_wherePopUpButton.menu indexOfItemWithTarget:self andAction:_cmd]; if(index != -1) - [self takeSearchTargetFrom:_wherePopUpButton.menu.itemArray[index]]; + [self orderFrontFindPanel:_wherePopUpButton.menu.itemArray[index]]; } - (void)goForward:(id)sender { NSInteger index = [_wherePopUpButton.menu indexOfItemWithTarget:self andAction:_cmd]; if(index != -1) - [self takeSearchTargetFrom:_wherePopUpButton.menu.itemArray[index]]; + [self orderFrontFindPanel:_wherePopUpButton.menu.itemArray[index]]; else if(_searchTarget == FFSearchTargetOther && _otherFolder) self.searchTarget = FFSearchTargetProject; }