A text field is a control, instantiated from the class NSTextField, 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 while editing. Like other controls, it also performs validation on its value when edited. If the value isn’t valid it sends a special error action message to its target.
There are several types of objects that display text, and in some cases, a text field may not be the right choice. If you need to enter more than one line of text, use a text view. If you need several related text fields, use a form.
You can link text fields together in their window’s key view loop, as described in “Implementing a Document-Based Application”.
An NSTextField object can be assigned a delegate, which is then sent delegate messages by the window’s field editor, such as textShouldEndEditing:
. See “Using the Window’s Field Editor” for more information on a window’s field editor.
A text field allows you to set the attributes of its text, the text background color, whether it draws the background, and whether it draws a bezel or border around its text. Note that the text and background colors of selected text are configurable. The selected text color overrides any actual text color applied to the text while it’s selected (this is generally the case with controls).
A text field is implemented by two classes: NSTextFieldCell, the cell which does most of the work, and NSTextField, the control that contains that cell. Every method in NSTextFieldCell has a cover in NSTextField. (A cover is a method of the same name that calls the original method.) An NSTextField can have a delegate that responds to such delegate methods as textShouldEndEditing:
.
© 1997, 2004 Apple Computer, Inc. All Rights Reserved. (Last updated: 2004-02-09)