Class

NSText​Field

An NSText​Field object is a kind of NSControl 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.

Overview

The NSText​Field class uses the NSText​Field​Cell class to implement its user interface.

The parent class, NSControl, provides the methods for setting the values of the text field, for example: string​Value, double​Value, etc.. There are corresponding methods to retrieve values.

Symbols

Controlling Selection and Editing

var is​Editable:​ Bool

A Boolean that controls whether the user can edit the receiver’s text.

var is​Selectable:​ Bool

A Boolean that determins whether the receiver is selectable (but not editable).

Controlling Rich Text Behavior

var allows​Editing​Text​Attributes:​ Bool

A Boolean that controls whether the receiver allows the user to change font attributes of the receiver’s string.

var imports​Graphics:​ Bool

A Boolean that controls whether the receiver allows the user to drag image files into it.

Setting the Text Color

var text​Color:​ NSColor?

The color used to draw the receiver’s text.

Auto Layout Sizing

var preferred​Max​Layout​Width:​ CGFloat

The preferred maximum layout width.

Controlling the Background

var background​Color:​ NSColor?

The color of the background that the receiver’s cell draws behind the text.

var draws​Background:​ Bool

A Boolean that controls whether the receiver’s cell draws its background color behind its text

Setting a Border

var is​Bezeled:​ Bool

A Boolean that controls whether the receiver draws a bezeled border around its contents.

var is​Bordered:​ Bool

A Boolean that controls whether the receiver draws a solid black border around its contents.

Selecting the Text

func select​Text(Any?)

Ends editing and selects the entire contents of the receiver if it’s selectable.

Working with the Responder Chain

var accepts​First​Responder:​ Bool

A Boolean value indicating whether the receiver is editable.

Setting the Delegate

NSText Delegate Method Implementations

func text​Should​Begin​Editing(NSText)

Requests permission to begin editing a text object.

func text​Did​Begin​Editing(Notification)

Posts a notification that the text is about to begin editing to the default notification center.

func text​Did​Change(Notification)

Posts a notification that the text has changed and forwards this message to the receiver’s cell if it responds.

func text​Should​End​Editing(NSText)

Performs validation on the receiver’s new value.