I have a simple cocoa user interface with a list of items and a search field, implemented using NSTableView and NSSearchField, respectively. The data source and all of the bindings are set up and working nicely. I see my data in the list, and I can search through it by typing strings in the search field. As I type in more text, the number of items in the list gets smaller and smaller, eventually reduced to the one item I was searching for.
Now, how can I clear the text in the search field and force the list to go back to normal? I can make this happen by clearing the text manually (using the keyboard), but when I try to do it programmatically, the hidden items in the list do not come back.
I'm using this:
[searchField setStringValue:@""];
to clear the text in the search field, but it does not reset the list.
Any ideas? Is there a simple [searchField reset] method that I just can't find in the documentation?
I figured it out. The following code works:
[searchField setStringValue:@""]; [[[searchField cell] cancelButtonCell] performClick:self];
I figured it out. The following code works:
[searchField setStringValue:@""];
[[[searchField cell] cancelButtonCell] performClick:self];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With