NSTextFieldCell Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | Text Fields |
| Declared in | NSTextFieldCell.h |
Overview
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 setPlaceholderString: or setPlaceholderAttributedString:, 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:.
Tasks
Setting the Text Color
Setting the Bezel Style
Controlling the Background
Managing the Field Editor
Managing Placeholder Strings
-
– setPlaceholderString: -
– placeholderString -
– setPlaceholderAttributedString: -
– placeholderAttributedString
Accessing Input Source Locales
Instance Methods
allowedInputSourceLocales
Returns an array of locale identifiers representing input sources that are allowed to be enabled when the receiver has the keyboard focus.
Return Value
The locale identifiers of allowed input sources.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTextFieldCell.hbackgroundColor
Returns the color of the background the receiver draws behind the text.
Return Value
The background color of the text field cell.
Availability
- Available in OS X v10.0 and later.
See Also
-
– drawsBackground -
– backgroundColor(NSTextField) -
– setBackgroundColor:
Declared In
NSTextFieldCell.hbezelStyle
Returns the receiver’s bezel style.
Return Value
A constant indicating the bezel style of the text field cell. See NSTextFieldBezelStyle.
Availability
- Available in OS X v10.2 and later.
See Also
Declared In
NSTextFieldCell.hdrawsBackground
Returns a Boolean value that indicates whether the receiver draws its background color.
Return Value
YES if the receiver draws its background color behind its text, NO if it draws no background.
Discussion
In order to prevent inconsistent rendering, background color rendering is disabled for rounded-bezel text fields.
Availability
- Available in OS X v10.0 and later.
See Also
-
– backgroundColor -
– drawsBackground(NSTextField) -
– setDrawsBackground:
Declared In
NSTextFieldCell.hplaceholderAttributedString
Returns the cell’s attributed placeholder string.
Return Value
The attributed string used as the cell's placeholder.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextFieldCell.hplaceholderString
Returns the cell’s plain text placeholder string.
Return Value
The cell''s placeholder string.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextFieldCell.hsetAllowedInputSourceLocales:
Sets an array of locale identifiers representing input sources that are allowed to be enabled when the receiver has the keyboard focus.
Parameters
- localeIdentifiers
The new locale identifiers of allowed input sources.
Discussion
You can use the meta-locale identifier, NSAllRomanInputSourcesLocaleIdentifier, to specify input sources that are limited for Roman script editing.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSTextFieldCell.hsetBackgroundColor:
Sets the color of the background that the receiver draws behind the text.
Parameters
- aColor
The background color of the text field cell.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setDrawsBackground: -
– setBackgroundColor:(NSTextField) -
– backgroundColor
Declared In
NSTextFieldCell.hsetBezelStyle:
Sets the receiver’s bezel style.
Parameters
- style
A constant specifying the bezel style of the text field cell. See
NSTextFieldBezelStyle.
Discussion
To set the bezel style, you must have already sent setBezeled: with an argument of YES.
Availability
- Available in OS X v10.2 and later.
See Also
Declared In
NSTextFieldCell.hsetDrawsBackground:
Controls whether the receiver draws its background color behind its text.
Discussion
In order to prevent inconsistent rendering, background color rendering is disabled for rounded-bezel text fields.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setBackgroundColor: -
– setDrawsBackground:(NSTextField) -
– drawsBackground
Declared In
NSTextFieldCell.hsetPlaceholderAttributedString:
Sets the placeholder of the cell as an attributed string.
Return Value
The attributed string to use as a placeholder.
Discussion
Note that invoking this successfully will clear out any plain text string set by setPlaceholderString:.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextFieldCell.hsetPlaceholderString:
Sets the placeholder of the cell as a plain text string.
Parameters
- string
The placeholder string.
Discussion
Note that invoking this successfully will clear out any attributed string set by setPlaceholderAttributedString:.
Availability
- Available in OS X v10.3 and later.
Declared In
NSTextFieldCell.hsetTextColor:
Sets the color used to draw the receiver’s text.
Parameters
- aColor
The color used to draw the text.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setBackgroundColor: -
– setTextColor:(NSTextField) -
– textColor
Declared In
NSTextFieldCell.hsetUpFieldEditorAttributes:
Sets up the field editor. You never invoke this method directly; by overriding it, however, you can customize the field editor.
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”.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTextFieldCell.hsetWantsNotificationForMarkedText:
Directs the cell’s associated field editor to post text change notifications.
Parameters
Availability
- Available in OS X v10.5 and later.
Declared In
NSTextFieldCell.htextColor
Returns the color used to draw the receiver’s text.
Return Value
The color used to draw the text.
Availability
- Available in OS X v10.0 and later.
See Also
-
– backgroundColor -
– textColor(NSTextField) -
– setTextColor:
Declared In
NSTextFieldCell.hConstants
NSTextFieldBezelStyle
Specify the bezel style of the text field cell.
enum {
NSTextFieldSquareBezel = 0,
NSTextFieldRoundedBezel = 1
};
typedef NSUInteger NSTextFieldBezelStyle;
Constants
NSTextFieldSquareBezelCorners are square.
Available in OS X v10.2 and later.
Declared in
NSTextFieldCell.h.NSTextFieldRoundedBezelCorners are rounded.
Available in OS X v10.2 and later.
Declared in
NSTextFieldCell.h.
Discussion
The bezel style of a text field is set using the bezelStyle and setBezelStyle: methods.
Availability
- Available in OS X v10.2 and later.
Declared In
NSTextFieldCell.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-03-26)