title: How to implement a search field like the one in Finder
body: <p><a href="https://i.stack.imgur.com/P8bNr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P8bNr.png" alt="Finder&#39;s search field"></a></p>
  
  <p>In my OS X app (with Cocoa), I want to implement a search field like the one in Finder(see the screen shot above).</p>
  
  <p>I'm considering subclassing <code>NSSearchField</code> and <code>NSSearchFieldCell</code>. The latter should be responsible for managing the "tokens". I have read <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaViewsGuide/Introduction/Introduction.html" rel="nofollow noreferrer">View Programming Guide</a>, <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ControlCell/ControlCell.html" rel="nofollow noreferrer">Control and Cell Programming Topics</a> and the docs of <code>NSTokenField[Cell]</code>, <code>NSSearchField[Cell]</code>, <code>NSCell</code>.</p>
  
  <p>A few things are unclear to me:</p>
  
  <p>1) In the subclass, how can I reuse the magnifier icon which may be provided by <code>NSSearchFieldCell</code>? Is the icon an <code>NSImage</code>? There's an animation for it, what should I learn If I have to implement the animation by myself?</p>
  
  <p>2) What should be used to implement the dropdown button (like the "NAME" button in the example image). What class to use to group the search category (e.g. "NAME") and the keyword (e.g. "yh")? What's the "arrow" following "NAME"?</p>
  
  <p>Any books, articles or other resource recommendations are also welcome.</p>
  
  <p>A similar and related question is <a href="https://stackoverflow.com/questions/8643690/mail-like-search-field-with-tokens-mac-os-x-10-7">Mail like search field with tokens (Mac OS X 10.7)</a></p>
  
  <h2>Update on 2015-07-26:</h2>
  
  <p>The usage of NSCell has changed since Yosemite, <a href="https://stackoverflow.com/questions/28700605/how-to-create-a-custom-themed-nsbutton-without-subclassing-nsbuttoncell">
  How to create a custom themed NSButton without subclassing NSButtonCell?
  </a> is related to that topic. Cells will be deprecated, so it's not wise to use it.</p>