Re: NSSearchField loses focus
Re: NSSearchField loses focus
- Subject: Re: NSSearchField loses focus
- From: Peer Allan <email@hidden>
- Date: Wed, 21 Jan 2004 13:27:09 -0600
Thanks for the reply Justin. Sure enough the sorting problem is
working, but removing the value binding on the search string did not.
When I do a check on its value in the search method it is always null.
I am assuming that the likely cause of this is that the searchString is
no longer accessible.
I attempted to make an outlet for the search field, but that had no
effect. I am going to keep playing with it, but if anyone has any other
suggestions I would appreciate it.
Peer
On Jan 21, 2004, at 12:23 PM, Justin Anderson wrote:
Well the reason you don't get sorting with an empty searchString is
because you return the array "as is" in the first 2 lines of the
method. I had to deal with both of the problems you're having a couple
days ago. Sorting takes place in [super
arrangeObjects:filteredObjects], so you'll want to always call that at
the end of your subclass. Better code would be:
- (NSArray *)arrangeObjects:(NSArray *)objects {
if (searchString == nil) {
return [super arrangeObjects:objects];
}
//snip... lala...
}
And the NSSearchField loses focus because of the way the example has
you set it up in IB. They make you connect it's search action but also
bind it's value to searchString in your array controller. What ends up
happening is:
NSSearchField calls the -search: action after timeout.
Array controller sets searchString from NSSearchField.
Binding causes NSSearchField to update itself with the "new" value in
searchString.
Updating NSSearchField's value causes you to lose focus.
So get rid of the value binding on NSSearchField and you'll keep
focus. I *think* that's all I had to do. If not, I'll pull out my old
project.
- Justin Anderson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.