Next Page > Hide TOC

Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

NSTextFieldCell

Inherits from
Implements
Package
com.apple.cocoa.application
Companion guide

Overview

NSTextFieldCell adds to NSCell’s text display capabilities 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 NSTextField, which uses NSTextFieldCells to draw and edit text.

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

Tasks

Constructors

Setting the Text Color

Setting the Bezel Style

Controlling the Background

Changing the Field Editor

Managing Placeholder Strings

Constructors

NSTextFieldCell

Creates an empty NSTextFieldCell.

public NSTextFieldCell()

Creates an NSTextFieldCell initialized with aString and set to have the cell’s default menu.

public NSTextFieldCell(String aString)

Discussion

If no field editor has been created, one is created.

Creates an NSTextFieldCell initialized with anImage and set to have the cell’s default menu.

public NSTextFieldCell(NSImage anImage)

Discussion

If anImage is null, no image is set.

Instance Methods

backgroundColor

Returns the color of the background the receiver draws behind the text.

public NSColor backgroundColor()

See Also

bezelStyle

Returns the receiver’s bezel style.

public int bezelStyle()

Discussion

Possible return values are described in “Constants.”

Availability
See Also

drawsBackground

Returns true if the receiver’s cell draws its background color behind its text, false if it draws no background.

public boolean drawsBackground()

See Also

placeholderAttributedString

Returns the cell’s attributed placeholder string.

public NSAttributedString placeholderAttributedString()

Availability
See Also

placeholderString

Returns the cell’s plain text placeholder string.

public String placeholderString()

Availability
See Also

setBackgroundColor

Sets the color of the background that the receiver draws behind the text to aColor.

public void setBackgroundColor(NSColor aColor)

See Also

setBezelStyle

Sets the receiver’s bezel style to be style.

public void setBezelStyle(int style)

Discussion

Possible values for style are described in “Constants.” You must have already sent setBezeled with an argument of true.

Availability
See Also

setDrawsBackground

Controls whether the receiver draws its background color behind its text.

public void setDrawsBackground(boolean flag)

Discussion

If flag is true, then it does; if flag is false, then it draws nothing behind its text.

See Also

setPlaceholderAttributedString

Sets the placeholder of the cell as an attributed string.

public void setPlaceholderAttributedString(NSAttributedString string)

Discussion

Note that invoking this successfully will clear out the plain text string set by setPlaceholderString.

Availability
See Also

setPlaceholderString

Sets the placeholder of the cell as a plain text string.

public void setPlaceholderString(String string)

Discussion

Note that invoking this successfully will clear out the attributed string set by setPlaceholderAttributedString.

Availability
See Also

setTextColor

Sets the color used to draw the receiver’s text to aColor.

public void setTextColor(NSColor aColor)

See Also

setUpFieldEditorAttributes

public NSText setUpFieldEditorAttributes(NSText textObj)

Discussion

You never invoke this method directly; by overriding it, however, you can customize or replace the field editor. 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”.

textColor

Returns the color used to draw the receiver’s text.

public NSColor textColor()

See Also

Constants

The following constants are specify the bezel style of the text field, and are set using bezelStyle and setBezelStyle.

Constant

Description

TextFieldSquareBezel

Corners are square.

TextFieldRoundedBezel

Corners are rounded.



Next Page > Hide TOC


© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.