Search code examples
cocoanstextfieldnsbutton

NSTextField add cancel button


Using iOS and a UISearchBar you can have a nice little cancel button setup within the text field similar to this:

enter image description here

(Note I found the image on another post and the 'argh!' is not relevant in my case).

Now in my case i'm using cocoa and a NSTextField and i'm wondering what the easiest way to have something similar added would be. Worse case scenario I will create a custom NSTextField with an image/button on it, but I would prefer to not reinvent the wheel if I am missing an obvious way to do this.


Solution

  • I somehow overlooked the NSSearchField component which does basically exactly this.