An object that enhances the text display capabilities of a cell.


class NSTextFieldCell : NSActionCell


The NSTextFieldCell class adds to the text display capabilities of the NSCell class by allowing you to set the color of both the text and its background. You can also specify whether the cell draws its background at all.

All of the methods declared by this class are also declared by the NSTextField class, which uses NSTextFieldCell objects to draw and edit text. These NSTextField cover methods call the corresponding NSTextFieldCell methods.

Placeholder strings, set using the placeholderString or placeholderAttributedString property, now appear in the text field cell if the actual string is nil or @"". They are drawn in grey on the cell and are not archived in the “pre-10.2” nib format.

Designated Initializers

When subclassing NSTextFieldCell you must implement all of the designated initializers. Those methods are: init(coder:), init(textCell:), and init(imageCell:).


Setting the Text Color

var textColor: NSColor?

The color used to draw the cell’s text.

Setting the Bezel Style

var bezelStyle: NSTextField.BezelStyle

The bezel style to use when drawing the text field.

Controlling the Background

var backgroundColor: NSColor?

The color of the cell’s background.

var drawsBackground: Bool

A Boolean value indicating whether the cell draws its background color.

Managing the Field Editor

func setUpFieldEditorAttributes(NSText) -> NSText

Sets up the field editor. You never invoke this method directly; by overriding it, however, you can customize the field editor.

func setWantsNotificationForMarkedText(Bool)

Directs the cell’s associated field editor to post text change notifications.

Managing Placeholder Strings

var placeholderString: String?

The placeholder text for the cell, specified as a plain text string.

var placeholderAttributedString: NSAttributedString?

The placeholder text for the cell, specified as an attributed string.

Accessing Input Source Locales

var allowedInputSourceLocales: [String]?

An array of locale identifiers representing the allowed input sources when the text field has the keyboard focus.


enum NSTextField.BezelStyle

Specify the bezel style of the text field cell.


Inherits From

Conforms To

See Also


class NSSecureTextFieldCell

A text field whose value is hidden from the user.