Reputation: 1913
On the iPhone a UITextField
can have a clearButtonMode set to show a small clear button (X) at the end of a text input. Similarly, on the Mac the NSSearchField
has a nice clear button on it at the end. My question is - is there a way to enable this on a normal NSTextField
?
Upvotes: 7
Views: 4617
Reputation: 6932
I was looking for the same thing for a multi-lined NSTextField the other day, with no luck so ended up using a button set with no border and to toggle with a small image. set very close to the NSTextField (not on it)
and:
- (IBAction)clearTextViewTex:(id)sender{
[textField performSelector:@selector(selectAll:)];
[textField performSelector:@selector(delete:)];
}
Doing it this way also retained the undo functions, without me having to write any NSUndoManager stuff.
Upvotes: 1
Reputation: 15013
There's nothing built-in; just use a search field and turn off the magnifying glass:
[[button cell] setSearchButtonCell:nil];
Upvotes: 12