Next Page > Hide TOC

Legacy Documentclose button

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

NSActionCell

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

Overview

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

An NSActionCell defines an active area inside a control (an instance of NSControl or one of its subclasses). As an NSControl’s active area, an NSActionCell does three things: it usually performs display of text or an icon; it provides the NSControl with a target and an action; and it handles mouse (cursor) tracking by properly highlighting its area and sending action messages to its target based on cursor movement.

Tasks

Constructors

Configuring an NSActionCell

Obtaining and Setting Cell Values

Getting and Setting the Cell’s View

Assigning Target and Action

Assigning a Tag

Constructors

NSActionCell

Creates an empty NSActionCell.

public NSActionCell()

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

public NSActionCell(String aString)

Discussion

If no field editor (a shared NSText object) has been created for all NSActionCells, one is created.

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

public NSActionCell(NSImage anImage)

Discussion

If anImage is null, no image is set.

Instance Methods

action

Returns the receiver’s action message selector.

public NSSelector action()

See Also

controlView

Returns the view (normally an NSControl) in which the receiver was last drawn or null if the receiver has no control view (usually because it hasn’t yet been placed in the view hierarchy).

public NSView controlView()

doubleValue

Returns the receiver’s value as a double after validating any editing of cell content.

public double doubleValue()

Discussion

If the receiver is not a text-type cell or the cell value is not scannable, the method returns 0.

See Also

floatValue

Returns the receiver’s value as a float after validating any editing of cell content.

public float floatValue()

Discussion

If the receiver is not a text-type cell or the cell value is not scannable, the method returns 0.

See Also

intValue

Returns the receiver’s value as an int after validating any editing of cell content.

public int intValue()

Discussion

If the receiver is not a text-type cell or the cell value is not scannable, the method returns 0.

See Also

setAction

Sets the selector used for the action message to aSelector.

public void setAction(NSSelector aSelector)

See Also

setAlignment

Sets the alignment of text in the receiver.

public void setAlignment(int mode)

Discussion

mode is one of five constants: NSText.LeftTextAlignment, NSText.RightTextAlignment, NSText.CenterTextAlignment, NSText.JustifiedTextAlignment, and NSText.NaturalTextAlignment (the default alignment for the text). The method marks the receiver as needing redisplay after discarding any editing changes that were being made to cell text.

setBezeled

Sets whether the receiver draws itself with a bezeled border and marks it as needing redisplay.

public void setBezeled(boolean flag)

Discussion

The setBezeled and setBordered methods are mutually exclusive—that is, a border can be only plain or bezeled.

setBordered

Sets whether the receiver draws itself outlined with a plain border and marks it as needing redisplay.

public void setBordered(boolean flag)

Discussion

The setBezeled and setBordered methods are mutually exclusive—that is, a border can be only plain or bezeled.

setControlView

Sets the view (normally an NSControl) of the receiver to view.

public void setControlView(NSView view)

Discussion

The control view is typically set in the receiver’s implementation of drawWithFrameInView (NSCell). Set to null if the receiver has no control view (usually because it hasn’t yet been placed in the view hierarchy).

Availability

setEnabled

Sets whether the receiver is enabled or disabled.

public void setEnabled(boolean flag)

Discussion

The text of disabled cells is changed to gray. If a cell is disabled, it cannot be highlighted, does not support mouse tracking (and thus cannot participate in target/action functionality), and cannot be edited. The method marks the receiver as needing redisplay after discarding any editing changes that were being made to cell text.

setFloatingPointFormat

Sets the receiver’s floating-point format as described in the NSCell class specification for the setFloatingPointFormat method.

public void setFloatingPointFormat(boolean autoRange, int leftDigits, int rightDigits)

Discussion

NSActionCell’s implementation of the method supplements NSCell’s by marking the receiver as needing redisplay after discarding any editing changes that were being made to cell text.

setFont

Sets the font to be used when the receiver displays text.

public void setFont(NSFont fontObj)

Discussion

If the receiver is not a text-type cell, the method converts it to that type. If fontObj is null and the receiver is a text-type cell, the font currently held by the receiver is autoreleased. NSActionCell supplements NSCell’s implementation of this method by marking the updated cell as needing redisplay. If the receiver was converted to a text-type cell and is selected, it also updates the field editor with fontObj.

setImage

Sets the image to be displayed in the receiver.

public void setImage(NSImage image)

Discussion

If image is null, the image currently displayed by the receiver is removed.

setObjectValue

Discards any editing of the receiver’s text and sets its object value to object.

public void setObjectValue(Object object)

Discussion

If the object value is afterward different from what it was before the method was invoked, the method marks the receiver as needing redisplay.

setTag

Sets the receiver’s tag to anInt.

public void setTag(int anInt)

See Also

setTarget

Sets the receiver’s target object to anObject.

public void setTarget(Object anObject)

See Also

stringValue

Returns the receiver’s value as a string object as converted by the cell’s formatter, if one exists.

public String stringValue()

Discussion

If no formatter exists and the value is a String, returns the value as a plain, attributed, or localized formatted string. If the value is not a String or can’t be converted to one, returns an empty string. The method supplements NSCell’s implementation by validating and retaining any editing changes being made to cell text.

See Also

tag

Returns the receiver’s tag.

public int tag()

See Also

target

Returns the receiver’s target object.

public Object target()

See Also


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.