Don't give focus to search box when setting the reseting the text to empty string on OS X, otherwise it will get focus when it doesn't need to

This commit is contained in:
Arnaud Bienner 2015-09-21 00:21:39 +02:00
parent e83848edd1
commit bfe5042132
1 changed files with 4 additions and 2 deletions

View File

@ -166,8 +166,10 @@ void QSearchField::setText(const QString &text)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[pimpl->nsSearchField setStringValue:fromQString(text)];
[pimpl->nsSearchField selectText:pimpl->nsSearchField];
[[pimpl->nsSearchField currentEditor] setSelectedRange:NSMakeRange([[pimpl->nsSearchField stringValue] length], 0)];
if (!text.isEmpty()) {
[pimpl->nsSearchField selectText:pimpl->nsSearchField];
[[pimpl->nsSearchField currentEditor] setSelectedRange:NSMakeRange([[pimpl->nsSearchField stringValue] length], 0)];
}
[pool drain];
}