Check if Mac QSearchField has focus before handling the notification.

Otherwise, playlist's search field will always handle those shortcuts, and they won't work anywhere else on the same window.
Fixes #3320.
This commit is contained in:
Arnaud Bienner 2015-03-14 01:55:46 +01:00
parent fad0ccc8c6
commit fe7bc917de
1 changed files with 33 additions and 25 deletions

View File

@ -107,6 +107,13 @@ public:
@implementation QocoaSearchField
-(BOOL)performKeyEquivalent:(NSEvent*)event {
// First, check if we have the focus.
// If no, it probably means this event isn't for us.
NSResponder* firstResponder = [[NSApp keyWindow] firstResponder];
if ([firstResponder isKindOfClass:[NSText class]] &&
[(NSText*)firstResponder delegate] == self) {
if ([event type] == NSKeyDown && [event modifierFlags] & NSCommandKeyMask)
{
QString keyString = toQString([event characters]);
@ -135,6 +142,7 @@ public:
return YES;
}
}
}
return NO;
}