Search toggle now actually toggles.

This commit is contained in:
michael starke
2014-03-06 00:57:31 +01:00
parent fd2256917e
commit 41ba8f57ba
2 changed files with 9 additions and 5 deletions

View File

@@ -66,19 +66,20 @@ NSString *const kMPDocumentSearchResultsKey = @"kMPDocumentSearchResul
return; // We need to read the button state
}
MPEntrySearchFlags toggleFlag = [sender tag];
MPEntrySearchFlags newFlags = MPEntrySearchNone;
switch([sender state]) {
case NSOffState:
toggleFlag ^= MPEntrySearchAllFlags;
newFlags = self.activeFlags & toggleFlag;
break;
case NSOnState:
/* On is fine */
newFlags = self.activeFlags | toggleFlag;
break;
default:
NSAssert(NO, @"Internal state is inconsistent");
return;
}
MPEntrySearchFlags newFlags = self.activeFlags & toggleFlag;
if(newFlags == self.activeFlags) {
if(newFlags != self.activeFlags) {
self.activeFlags = (newFlags == MPEntrySearchNone) ? MPEntrySearchTitles : newFlags;
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidChangeSearchFlags object:self];
[self updateSearch:self];

View File

@@ -255,8 +255,11 @@ NSString *const MPToolbarItemSearch = @"TOOLBAR_SEARCH";
if(_displayModeBeforeSearch == NSToolbarDisplayModeLabelOnly) {
[self.toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
}
[[self.searchField window] makeFirstResponder:self.searchField];
[self.searchField selectText:self];
/* only make the searchfield first responder if it's not aleady in an active search */
if(![self.searchField currentEditor]) {
[[self.searchField window] makeFirstResponder:self.searchField];
[self.searchField selectText:self];
}
}
- (void)_didExitSearch:(NSNotification *)notification {