Mac Developer Library

Developer

AppKit Framework Reference NSTextFieldCell Class Reference

Options
Deployment Target:

On This Page
Language:

NSTextFieldCell

Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

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: initWithCoder:, initTextCell:, and initImageCell:.

  • textColor textColor Property

    The color used to draw the cell’s text.

    Declaration

    Swift

    @NSCopying var textColor: NSColor?

    Objective-C

    @property(copy) NSColor *textColor

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    backgroundColor
    – setTextColor: (NSTextField)

  • The bezel style to use when drawing the text field.

    Declaration

    Swift

    var bezelStyle: NSTextFieldBezelStyle

    Objective-C

    @property NSTextFieldBezelStyle bezelStyle

    Discussion

    To set the bezel style, you must have already set the the text field’s setBezeled: method with an argument of YEStrue. For a list of bezel styles, see NSTextFieldBezelStyle.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.

  • The color of the cell’s background.

    Declaration

    Swift

    @NSCopying var backgroundColor: NSColor?

    Objective-C

    @property(copy) NSColor *backgroundColor

    Discussion

    The background color is drawn behind the cell’s text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var drawsBackground: Bool

    Objective-C

    @property BOOL drawsBackground

    Discussion

    When the value of this property is YEStrue, the cell draws its background color. In order to prevent inconsistent rendering, background color rendering is automatically disabled for rounded-bezel text fields.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func setUpFieldEditorAttributes(_ textObj: NSText) -> NSText

    Objective-C

    - (NSText *)setUpFieldEditorAttributes:(NSText *)textObj

    Discussion

    When you override this method, you should generally invoke the implementation of super and return the textObj argument. For information on field editors, see Using the Window’s Field Editor.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func setWantsNotificationForMarkedText(_ flag: Bool)

    Objective-C

    - (void)setWantsNotificationForMarkedText:(BOOL)flag

    Parameters

    flag

    If YEStrue, the field editor posts text change notifications (NSTextDidChangeNotification) while editing marked text; if NOfalse, notifications are delayed until the marked text confirmation.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

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

    Declaration

    Swift

    var allowedInputSourceLocales: [AnyObject]?

    Objective-C

    @property(copy) NSArray *allowedInputSourceLocales

    Discussion

    The value of this property is an array of NSString objects, each of which contains a locale identifier. You can assign the meta-locale identifier, NSAllRomanInputSourcesLocaleIdentifier, to specify input sources that are limited for Roman script editing.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Specify the bezel style of the text field cell.

    Declaration

    Swift

    enum NSTextFieldBezelStyle : UInt { case SquareBezel case RoundedBezel }

    Objective-C

    typedef enum NSTextFieldBezelStyle : NSUInteger { NSTextFieldSquareBezel = 0, NSTextFieldRoundedBezel = 1 } NSTextFieldBezelStyle;

    Constants

    • SquareBezel

      NSTextFieldSquareBezel

      Corners are square.

      Available in OS X v10.2 and later.

    • RoundedBezel

      NSTextFieldRoundedBezel

      Corners are rounded.

      Available in OS X v10.2 and later.

    Discussion

    The bezel style of a text field is set using the bezelStyle property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.