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
?
There's nothing built-in; just use a search field and turn off the magnifying glass:
[[button cell] setSearchButtonCell:nil];
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.
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