Class

NSSearchField

A text field control that is optimized for performing text-based searches.

Declaration

class NSSearchField : NSTextField

Overview

NSSearchField provides a customized text field for entering search data, a search button, a cancel button, and a pop-up icon menu for listing recent search strings and custom search categories. An NSSearchField object wraps an NSSearchFieldCell object. Access to most search field attributes occurs through the cell, which provides a more comprehensive programmatic interface for manipulating the search field. You can use an NSSearchField object though to manipulate some aspects of the search field. For additional information about search fields and how to manipulate them, see the NSSearchFieldCell class.

Topics

Managing the Search

protocol NSSearchFieldDelegate

A protocol that a search field delegate can use to determine when a search started or ended.

Managing Menu Templates

var searchMenuTemplate: NSMenu?

The menu object used to dynamically construct the search field’s pop-up icon menu.

class let clearRecentsMenuItemTag: Int

Identifies the menu item for clearing the current set of recent string searches in the menu.

class let noRecentsMenuItemTag: Int

Identifies the menu item that describes a lack of recent search strings (for example, “No recent searches”).

class let recentsMenuItemTag: Int

Identifies where recent search strings should appear in the “recents” menu group.

class let recentsTitleMenuItemTag: Int

Identifies the menu item that is the title of the menu group for recent search strings.

Managing search modes

var sendsSearchStringImmediately: Bool

A Boolean value indicating whether the cell calls its action method immediately when an appropriate action occurs.

var sendsWholeSearchString: Bool

A Boolean value indicating whether the cell calls its search action method when the user clicks the search button (or presses Return) or after each keystroke.

Managing recent searches

var recentSearches: [String]

The list of recent search strings for the control.

Managing recent search strings

var maximumRecents: Int

The maximum number of search strings that can appear in the search menu.

var recentsAutosaveName: NSSearchField.RecentsAutosaveName?

The autosave name under which the receiver automatically archives the list of recent search strings

Configuring the Search Field