Re: Clear NSSearchField
Re: Clear NSSearchField
- Subject: Re: Clear NSSearchField
- From: Randy Widell <email@hidden>
- Date: Sat, 18 Oct 2014 15:03:27 -0700
Yeah, I tried that initially. An invalid parameter exception comes flying out of NSCell’s setStringValue.
> On Oct 18, 2014, at 14:59, Gerd Knops <email@hidden> wrote:
>
> Did you try to set it ti nil instead of an empty string?
>
> Gerd
>
>> On Oct 18, 2014, at 4:51 PM, Randy Widell <email@hidden> wrote:
>>
>> It looks like a couple of people have asked about this in the past, but none of the answers are working for me. I am trying to clear the contents of a NSSearchField and have it go back to its empty state. I don’t have a pre-Yosemite Mac handy to check if this is a bug / new behavior in Yosemite, however Apple Mail seems to be able to do it just fine.
>>
>> Most of the solutions I have seen are old and center around doing things like:
>>
>> [[searchField.cell cancelButtonCell] performClick: self];
>>
>> …or...
>>
>> searchField.stringValue = @“”;
>> [searchField validateEditing];
>>
>> Both of these methods do clear the NSSearchField’s string value, however the Cancel button remains visible and the search field does not go back to its empty state (magnifying glass centered, gray “Search” text placeholder, and Cancel button not visible).
>>
>> I have had some marginal success by modifying outlineViewSelectionDidChange: to set the search field’s stringValue to @“”, do what needs to be done to update the other views, set the search field to the first responder, and then set the outline view back to the first responder.
>>
>> That works somewhat, but not really. Half the time the search field remains the first responder as if the call to set the outline view as the first responder never happened.
>>
>> Any ideas?
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden