Mac OS X Reference Library Apple Developer
Search

Understanding Search Fields

A search field is a rounded text field that displays text that the user can select or edit, and that sends its action message to its target when the user presses the Return key. It presents a standard user interface for searches, including a search button, a cancel button, and a pop-up icon menu for listing recent search strings and custom search categories. The search button includes a menu and the option to send the results while the user is typing or when the user presses the Return key. If there is no text in the search field, the cancel button is hidden. Figure 1 shows the major components of a search field.

Figure 1  A search field

A search field

A search field is implemented by two classes: NSSearchFieldCell, the cell that does most of the work, and NSSearchField, the control that contains that cell.

There are, broadly speaking, two ways to configure and use a search field—programmatically, or with Cocoa bindings.

If you configure a search field programmatically, you should set the target and action of the control or its cell to the receiver that is interested in the search request. Also, remember that NSSearchFieldCell and NSSearchField classes are direct subclasses of NSTextFieldCell and NSTextField, respectively, so you can use all the methods inherited from these classes.




Last updated: 2008-02-08

Did this document help you? Yes It's good, but... Not helpful...