Clear NSSearchField
Clear NSSearchField
- Subject: Clear NSSearchField
- From: Randy Widell <email@hidden>
- Date: Sat, 18 Oct 2014 14:51:55 -0700
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