Using cancelOperation: since this is called by pressing the Esc key.

This commit is contained in:
Michael Starke
2019-10-30 16:38:29 +01:00
parent f1033c1006
commit e8a6af086c

View File

@@ -238,16 +238,18 @@ NSString *const MPToolbarItemAutotype = @"TOOLBAR_AUTOTYPE";
#pragma mark - NSSearchFieldDelegate
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector {
if(control != self.searchField) {
return NO;
}
if(commandSelector == @selector(insertNewline:) || commandSelector == @selector(moveDown:)) {
/* Dispatch the focus loss since doing it now will break recent search storage */
dispatch_async(dispatch_get_main_queue(), ^{
[[NSApp targetForAction:@selector(focusEntries:) to:nil from:self] focusEntries:self];
});
}
if(commandSelector == @selector(cancel:) && control == self.searchField) {
if(commandSelector == @selector(cancelOperation:) ) {
dispatch_async(dispatch_get_main_queue(), ^{
NSSearchFieldCell *cell = self.searchField.cell;
[[NSApp targetForAction:cell.cancelButtonCell.action to:nil from:self] exitSearch:nil];
[[NSApp targetForAction:@selector(exitSearch:) to:nil from:self] exitSearch:nil];
});
}
return NO;