Class

NSCell

A mechanism for displaying text or images in a view object without the overhead of a full NSView subclass.

Declaration

@interface NSCell : NSObject

Overview

Cells are used by most of the NSControl classes to implement their internal workings.

Designated Initializers

When subclassing NSCell you must implement all of the designated initializers. Those methods include init, initWithCoder:, initTextCell:, and initImageCell:.

Topics

Initializing a Cell

- initImageCell:

Returns an NSCell object initialized with the specified image and set to have the cell’s default menu.

- initTextCell:

Returns an NSCell object initialized with the specified string and set to have the cell’s default menu.

Managing Cell Values

objectValue

The cell’s value as an Objective-C object.

hasValidObjectValue

A Boolean value that indicates whether the cell has a valid object value.

intValue

The cell’s value as an integer.

integerValue

The cell’s value as an NSInteger type.

stringValue

The cell’s value as a string.

doubleValue

The cell’s value as a double-precision floating-point number.

floatValue

The cell’s value as a single-precision floating-point number.

Managing Cell Attributes

- setCellAttribute:to:

Sets the value for the specified cell attribute.

- cellAttribute:

Returns the value for the specified cell attribute.

type

The type of the cell.

enabled

A Boolean value indicating whether the cell is currently enabled.

allowsUndo

A Boolean value indicating whether the cell assumes responsibility for undo operations.

Managing Display Attributes

bezeled

A Boolean value indicating whether the cell has a bezeled border.

bordered

A Boolean value indicating whether the cell draws itself outlined with a plain border.

opaque

A Boolean value indicating whether the cell is completely opaque.

controlTint

The cell’s control tint.

Deprecated
backgroundStyle

The cell’s background style.

interiorBackgroundStyle

The cell’s interior background style.

NSBackgroundStyle

Background styles used with the backgroundStyle and interiorBackgroundStyle properties.

Managing Cell State

allowsMixedState

A Boolean value indicating whether the cell supports three states instead of two.

nextState

The cell’s next state.

- setNextState

Changes cell’s state to the next value in the sequence.

state

The cell’s current state.

Modifying Textual Attributes

editable

A Boolean value indicating whether the cell is editable.

selectable

A Boolean value indicating whether the cell’s text can be selected.

scrollable

A Boolean value indicating whether excess text scrolls past the cell’s bounds.

alignment

The alignment of the cell’s text.

font

The font that the cell uses to display text.

lineBreakMode

The line break mode to use when drawing text in the cell.

truncatesLastVisibleLine

A Boolean value indicating whether the cell truncates text that does not fit within the cell’s bounds.

wraps

A Boolean value indicating whether the cell wraps text whose length that exceeds the cell’s frame.

baseWritingDirection

The initial writing direction used to determine the actual writing direction for text.

attributedStringValue

The cell’s value as an attributed string.

allowsEditingTextAttributes

A Boolean value indicating whether the cell allows the editing of its content’s text attributes by the user.

importsGraphics

A Boolean value indicating whether the cell supports the importation of images into its text.

- setUpFieldEditorAttributes:

Configures the textual and background attributes of the receiver's field editor.

title

The cell’s title text.

Managing the Target and Action

action

The action performed by the cell.

target

The object that receives the cell’s action messages.

continuous

A Boolean value indicating whether the cell sends its action message continuously during mouse tracking.

- sendActionOn:

Sets the conditions on which the receiver sends action messages to its target.

Managing the Image

image

The image displayed by the cell, if any.

Managing the Tag

tag

A tag for identifying the cell.

Formatting and Validating Data

formatter

The cell’s formatter object.

Managing Menus

defaultMenu

Returns the default menu for instances of the cell.

menu

The cell’s contextual menu.

- menuForEvent:inRect:ofView:

Returns the menu associated with the cell and related to the specified event and frame.

Comparing Cells

- compare:

Compares the string values of the receiver another cell, disregarding case.

Respond to Keyboard Events

acceptsFirstResponder

A Boolean value indicating whether the cell accepts first responder status.

showsFirstResponder

A Boolean value indicating whether the cell provides a visual indication that it is the first responder.

refusesFirstResponder

A Boolean value indicating whether the cell refuses the first responder status.

- performClick:

Simulates a single mouse click on the receiver.

Deriving Values

- takeObjectValueFrom:

Sets the value of the receiver’s cell to the object value obtained from the specified object.

- takeIntegerValueFrom:

Sets the value of the receiver’s cell to an integer value obtained from the specified object.

- takeIntValueFrom:

Sets the value of the receiver’s cell to an integer value obtained from the specified object.

- takeStringValueFrom:

Sets the value of the receiver’s cell to the string value obtained from the specified object.

- takeDoubleValueFrom:

Sets the value of the receiver’s cell to a double-precision floating-point value obtained from the specified object.

- takeFloatValueFrom:

Sets the value of the receiver’s cell to a single-precision floating-point value obtained from the specified object.

Representing an Object

representedObject

The object represented by the cell.

Tracking the Mouse

- trackMouse:inRect:ofView:untilMouseUp:

Initiates the mouse tracking behavior in a cell.

- startTrackingAt:inView:

Begins tracking mouse events within the receiver.

- continueTracking:at:inView:

Returns a Boolean value that indicates whether mouse tracking should continue in the receiving cell.

- stopTracking:at:inView:mouseIsUp:

Stops tracking mouse events within the receiver.

mouseDownFlags

The modifier flags for the last (left) mouse-down event.

prefersTrackingUntilMouseUp

Returns a Boolean value that indicates whether tracking stops when the cursor leaves the cell.

- getPeriodicDelay:interval:

Returns the initial delay and repeat values for continuous sending of action messages to target objects.

Hit Testing

- hitTestForEvent:inRect:ofView:

Returns hit testing information for the receiver.

Managing the Cursor

- resetCursorRect:inView:

Sets the receiver to show the I-beam cursor while it tracks the mouse.

Handling Keyboard Alternatives

keyEquivalent

The key equivalent associated with clicking the cell.

Dragging Cells

- draggingImageComponentsWithFrame:inView:

Generates dragging image components with the specified frame in the view.

Managing Focus Rings

- drawFocusRingMaskWithFrame:inView:

Draws the focus ring for the control.

- focusRingMaskBoundsForFrame:inView:

Returns the bounds of the focus ring mask.

defaultFocusRingType

Returns the default type of focus ring for the receiver.

focusRingType

The type of focus ring to use with the associated view.

Determining Cell Size

- calcDrawInfo:

Recalculates the cell geometry.

cellSize

The minimum size needed to display the cell.

- cellSizeForBounds:

Returns the minimum size needed to display the receiver, constraining it to the specified rectangle.

- drawingRectForBounds:

Returns the rectangle within which the receiver draws itself

- imageRectForBounds:

Returns the rectangle in which the receiver draws its image.

- titleRectForBounds:

Returns the rectangle in which the receiver draws its title text.

controlSize

The size of the cell.

Drawing and Highlighting

- drawWithFrame:inView:

Draws the receiver’s border and then draws the interior of the cell.

- highlightColorWithFrame:inView:

Returns the color the receiver uses when drawing the selection highlight.

- drawInteriorWithFrame:inView:

Draws the interior portion of the receiver, which includes the image or text portion but does not include the border.

controlView

The view associated with the cell.

- highlight:withFrame:inView:

Redraws the receiver with the specified highlight setting.

highlighted

A Boolean value indicating whether the cell has a highlighted appearance.

Editing and Selecting Text

- editWithFrame:inView:editor:delegate:event:

Begins editing of the receiver’s text using the specified field editor.

- selectWithFrame:inView:editor:delegate:start:length:

Selects the specified text range in the cell's field editor.

sendsActionOnEndEditing

A Boolean value indicating whether the cell’s control object sends its action message when the user finishes editing the cell’s text.

- endEditing:

Ends the editing of text in the receiver using the specified field editor.

wantsNotificationForMarkedText

A Boolean value indicating whether the cell’s field editor should post text change notifications.

- fieldEditorForView:

Returns a custom field editor for editing in the view.

usesSingleLineMode

A Boolean value indicating whether the cell restricts layout and rendering of text to a single line.

Managing Expansion Frames

- expansionFrameWithFrame:inView:

Returns the expansion cell frame for the receiver.

- drawWithExpansionFrame:inView:

Instructs the receiver to draw in an expansion frame.

User Interface Layout Direction

userInterfaceLayoutDirection

The layout direction of the user interface.

Constants

NSCellType

Constants for specifying how a cell represents its data (as text or as an image).

NSCellAttribute

Constants for specifying how a button behaves when pressed and how it displays its state.

NSCellImagePosition

Constants for specifying the position of a button’s image relative to its title.

NSImageScaling

Constants that specify a cell’s image scaling behavior.

NSCellStateValue

Constants for specifying a cell’s state and are used mostly for buttons.

Deprecated
NSCellStyleMask

Constants for specifying what happens when a button is pressed or is displaying its alternate state.

NSControlTint

Constants for specifying a cell’s tint color.

NSControlSize

Constants for specifying a cell’s size.

NSCellHitResult

Constants used by the hitTestForEvent:inRect:ofView: method to determine the effect of an event.

NSBackgroundStyle

Background styles used with the backgroundStyle and interiorBackgroundStyle properties.

Deprecated Scaling Constants

These are deprecated scaling constants.

Data Entry Types

These constants specify how a cell formats numeric data.

Notifications

NSControlTintDidChangeNotification

Sent after the user changes control tint preference.

Deprecated

Deprecated Methods

- setEntryType:

Sets how numeric data is formatted in the receiver and places restrictions on acceptable input.

Deprecated
- entryType

Returns the type of data the user can type into the receiver.

Deprecated
- isEntryAcceptable:

Returns whether a string representing a numeric or date value is formatted in a suitable way for the cell's entry type.

Deprecated
- setFloatingPointFormat:left:right:

Sets the auto-ranging and floating point number format of the receiver’s cell.

Deprecated
- setTitleWithMnemonic:

Sets the title of the receiver with one character in the string denoted as an access key.

Deprecated
- mnemonic

Returns the character in the receiver’s title that appears underlined for use as a mnemonic.

Deprecated
- setMnemonicLocation:

Sets the character of the receiver’s title to be used as a mnemonic character.

Deprecated
- mnemonicLocation

Returns the position of the underlined mnemonic character in the receiver’s title.

Deprecated

See Also

View Fundamentals

NSView

The infrastructure for drawing, printing, and handling events in an app.

NSControl

A definition of the fundamental behavior for controls, which are specialized views that notify your app of relevant events by using the target-action design pattern.

NSActionCell

An active area inside a control.