Contents

NSTextField

Text the user can select or edit to send an action message to a target when the user presses the Return key.

Declaration

class NSTextField

Mentioned in

Overview

The NSTextField class uses the NSTextFieldCell class to implement its user interface. Text fields display text either as a static label or as an editable input field. The content of a text field is either plain text or a rich-text attributed string. Text fields also support line wrapping to display multiline text, and a variety of truncation styles if the content doesn’t fit the available space.

The parent class, NSControl, provides the methods for setting the values of the text field, such as stringValue and doubleValue. There are corresponding methods to retrieve values.

Topics

Creating text fields

Controlling selection and editing

Controlling rich text behavior

Setting placeholder text

Configuring line wrapping

Setting the text alignment

Sizing with Auto Layout

Setting the text color

Controlling the background

Setting a border

Selecting the text

Working with the responder chain

Using keyboard interface control

Supporting text completion and suggestions

Supporting Writing Tools

Setting the delegate

Implementing delegate methods

See Also

Text views