Hi all I am struggling to solve this problem. I wish to implement a searchField similar to the "Find" of Xcode's IDE editor, where, for example, "Recent Results" places the item chose into the SearchField and performs the search with the chosen string. The current setup( in OSx) is a simple TableView, an Array controller which populates the tableView with Managed Object instances, and works as expected. ( ie Add, Remove are implemented through the controller). I have implemented the direct search by creating a predicate with the inputString of the searchField and applying that to the arrayController, which works as expected. (done in the delegate ControlTextDidChange method);
The code I am using to try to implement the issue mentioned above is as follows. (unapologetically "modified" from Apple's searchField example)
-(void)setUpSearchField{
if ([self.searchField respondsToSelector:@selector(setRecentSearches:)]) {
NSMenu * searchMenu = [[NSMenu alloc]initWithTitle:@"Search Menu"]; [searchMenu setAutoenablesItems:YES];
NSMenuItem * recentSearchesItem = [[NSMenuItem alloc]initWithTitle:@"Recent Names" action:@selector(searchWithRecentNames:) keyEquivalent:@""]; [recentSearchesItem setTarget:self]; [recentSearchesItem setTag:NSSearchFieldRecentsMenuItemTag]; [searchMenu insertItem:recentSearchesItem atIndex:0];
id searchCell = [self.searchField cell]; [searchCell setSearchMenuTemplate:searchMenu];
}
}
The selector is never called. I have tried various delegate methods, but none are ever called. A pointer in the right direction would be greatly appreciated. Thanks in advance.
|