Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AppKit.framework |
Availability | Available in Mac OS X v10.0 and later. |
Companion guide | |
Declared in | NSTextFieldCell.h |
Related sample code |
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.
– setPlaceholderString:
– placeholderString
– setPlaceholderAttributedString:
– placeholderAttributedString
Returns an array of locale identifiers representing input sources that are allowed to be enabled when the receiver has the keyboard focus.
- (NSArray *)allowedInputSourceLocales
The locale identifiers of allowed input sources.
NSTextFieldCell.h
Returns the color of the background the receiver draws behind the text.
- (NSColor *)backgroundColor
The background color of the text field cell.
– drawsBackground
– backgroundColor
(NSTextField
)– setBackgroundColor:
NSTextFieldCell.h
Returns the receiver’s bezel style.
- (NSTextFieldBezelStyle)bezelStyle
A constant indicating the bezel style of the text field cell. See NSTextFieldBezelStyle
.
NSTextFieldCell.h
Returns a Boolean value that indicates whether the receiver draws its background color.
- (BOOL)drawsBackground
YES
if the receiver draws its background color behind its text, NO
if it draws no background.
In order to prevent inconsistent rendering, background color rendering is disabled for rounded-bezel text fields.
– backgroundColor
– drawsBackground
(NSTextField
)– setDrawsBackground:
NSTextFieldCell.h
Returns the cell’s attributed placeholder string.
- (NSAttributedString *)placeholderAttributedString
The attributed string used as the cell's placeholder.
NSTextFieldCell.h
Returns the cell’s plain text placeholder string.
- (NSString *)placeholderString
The cell''s placeholder string.
NSTextFieldCell.h
Sets an array of locale identifiers representing input sources that are allowed to be enabled when the receiver has the keyboard focus.
- (void)setAllowedInputSourceLocales:(NSArray *)localeIdentifiers
The new locale identifiers of allowed input sources.
You can use the meta-locale identifier, NSAllRomanInputSourcesLocaleIdentifier
, to specify input sources that are limited for Roman script editing.
NSTextFieldCell.h
Sets the color of the background that the receiver draws behind the text.
- (void)setBackgroundColor:(NSColor *)aColor
The background color of the text field cell.
– setDrawsBackground:
– setBackgroundColor:
(NSTextField
)– backgroundColor
NSTextFieldCell.h
Sets the receiver’s bezel style.
- (void)setBezelStyle:(NSTextFieldBezelStyle)style
A constant specifying the bezel style of the text field cell. See NSTextFieldBezelStyle
.
To set the bezel style, you must have already sent setBezeled:
with an argument of YES
.
NSTextFieldCell.h
Controls whether the receiver draws its background color behind its text.
- (void)setDrawsBackground:(BOOL)flag
In order to prevent inconsistent rendering, background color rendering is disabled for rounded-bezel text fields.
– setBackgroundColor:
– setDrawsBackground:
(NSTextField
)– drawsBackground
NSTextFieldCell.h
Sets the placeholder of the cell as an attributed string.
- (void)setPlaceholderAttributedString:(NSAttributedString *)string
The attributed string to use as a placeholder.
Note that invoking this successfully will clear out any plain text string set by setPlaceholderString:
.
NSTextFieldCell.h
Sets the placeholder of the cell as a plain text string.
- (void)setPlaceholderString:(NSString *)string
The placeholder string.
Note that invoking this successfully will clear out any attributed string set by setPlaceholderAttributedString:
.
NSTextFieldCell.h
Sets the color used to draw the receiver’s text.
- (void)setTextColor:(NSColor *)aColor
The color used to draw the text.
– setBackgroundColor:
– setTextColor:
(NSTextField
)– textColor
NSTextFieldCell.h
Sets up the field editor. You never invoke this method directly; by overriding it, however, you can customize the field editor.
- (NSText *)setUpFieldEditorAttributes:(NSText *)textObj
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”.
NSTextFieldCell.h
Directs the cell’s associated field editor to post text change notifications.
- (void)setWantsNotificationForMarkedText:(BOOL)flag
If YES
, the field editor posts text change notifications (NSTextDidChangeNotification
) while editing marked text; if NO
, notifications are delayed until the marked text confirmation.
NSTextFieldCell.h
Returns the color used to draw the receiver’s text.
- (NSColor *)textColor
The color used to draw the text.
– backgroundColor
– textColor
(NSTextField
)– setTextColor:
NSTextFieldCell.h
Specify the bezel style of the text field cell.
typedef enum { NSTextFieldSquareBezel = 0, NSTextFieldRoundedBezel = 1 } NSTextFieldBezelStyle;
NSTextFieldSquareBezel
Corners are square.
Available in Mac OS X v10.2 and later.
Declared in NSTextFieldCell.h
.
NSTextFieldRoundedBezel
Corners are rounded.
Available in Mac OS X v10.2 and later.
Declared in NSTextFieldCell.h
.
The bezel style of a text field is set using the bezelStyle
and setBezelStyle:
methods.
NSTextFieldCell.h
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)