Mac Developer Library

Developer

AppKit Framework Reference NSCell Class Reference

Options
Deployment Target:

On This Page
Language:

NSCell

Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

The NSCell class provides a mechanism for displaying text or images in an NSView object without the overhead of a full NSView subclass. It’s used heavily 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:.

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

    Declaration

    Swift

    init(imageCell anImage: NSImage?)

    Objective-C

    - (instancetype)initImageCell:(NSImage *)anImage

    Parameters

    anImage

    The image to use for the cell. If this parameter is nil, no image is set.

    Return Value

    An initialized NSCell object, or nil if the cell could not be initialized.

    Discussion

    This is one of four designated initializers you must implement when subclassing. See Designated Initializers for the complete list.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    init(textCell aString: String)

    Objective-C

    - (instancetype)initTextCell:(NSString *)aString

    Parameters

    aString

    The initial string to use for the cell.

    Return Value

    An initialized NSCell object, or nil if the cell could not be initialized.

    Discussion

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

    This is one of four designated initializers you must implement when subclassing. See Designated Initializers for the complete list.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    @NSCopying var objectValue: AnyObject?

    Objective-C

    @property(copy) id objectValue

    Discussion

    To be valid object value, the cell must have a formatter capable of converting the object to and from its textual representation. The value of this property is nil if an object has not been assigned to the cell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the cell has a valid object value. (read-only)

    Declaration

    Swift

    var hasValidObjectValue: Bool { get }

    Objective-C

    @property(readonly) BOOL hasValidObjectValue

    Discussion

    The value of this property is YEStrue if the cell has a valid object value or NOfalse if it does not. A valid object value is one that the cell’s formatter can "understand." Objects are always assumed to be valid unless they are rejected by the formatter. Invalid objects can still be accepted by the delegate of the cell’s NSControl object (using the control:didFailToFormatString:errorDescription: delegate method).

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    objectValue

  • intValue intValue Property

    The cell’s value as an integer.

    Declaration

    Swift

    var intValue: Int32

    Objective-C

    @property int intValue

    Discussion

    Use the integerValue property instead.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    integerValue

  • The cell’s value as an NSInteger type.

    Declaration

    Swift

    var integerValue: Int

    Objective-C

    @property NSInteger integerValue

    Discussion

    This property uses the objectValue property to access the actual value. If the cell is not a text-type cell or its contents are not scannable, the value in this property is 0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • The cell’s value as a string.

    Declaration

    Swift

    var stringValue: String

    Objective-C

    @property(copy) NSString *stringValue

    Discussion

    This property uses the objectValue property to access the actual value. If no formatter is assigned to the cell or if the formatter cannot “translate” a new string appropriately, the cell is flagged as having an invalid object. If the cell’s object is not an NSString object or cannot be converted to one, this property contains an empty string. If the cell is not a text-type cell, this method converts it to one before setting the object value.

    If you use a class that has an attributedStringValue property, the cell gets the string from that property instead of this one.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var doubleValue: Double

    Objective-C

    @property double doubleValue

    Discussion

    This property uses the objectValue property to access the actual value. If the cell is not a text-type cell or the cell’s value is not scannable, this property contains the value 0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var floatValue: Float

    Objective-C

    @property float floatValue

    Discussion

    This property uses the objectValue property to access the actual value. If the cell is not a text-type cell or the cell’s value is not scannable, this property contains the value 0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the value for the specified cell attribute.

    Declaration

    Swift

    func setCellAttribute(_ aParameter: NSCellAttribute, to value: Int)

    Objective-C

    - (void)setCellAttribute:(NSCellAttribute)aParameter to:(NSInteger)value

    Parameters

    aParameter

    The cell attribute whose value you want to set. Attributes include the receiver's current state and whether it is disabled, editable, or highlighted.

    value

    The new value for the attribute.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the value for the specified cell attribute.

    Declaration

    Swift

    func cellAttribute(_ aParameter: NSCellAttribute) -> Int

    Objective-C

    - (NSInteger)cellAttribute:(NSCellAttribute)aParameter

    Parameters

    aParameter

    The cell attribute whose value you want to get. Attributes include the receiver's current state and whether it is disabled, editable, or highlighted.

    Return Value

    The value for the cell attribute specified by aParameter.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • type type Property

    The type of the cell.

    Declaration

    Swift

    var type: NSCellType

    Objective-C

    @property NSCellType type

    Discussion

    When you change the cell type to NSTextCellType, the cell converts gives itself a default title and sets the font to the system font at the default size. When you change the cell type to NSImageCellType, the cell type does not change until you assign a new non-nil image to it.

    For a list of possible cell types, see NSCellType.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    image

  • enabled enabled Property

    A Boolean value indicating whether the cell is currently enabled.

    Declaration

    Swift

    var enabled: Bool

    Objective-C

    @property(getter=isEnabled) BOOL enabled

    Discussion

    The value of this property is YEStrue when the cell is enabled or NOfalse when it is disabled. The text of disabled cells is 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. However, you can still alter many attributes of a disabled cell programmatically. (The state property, for instance, still works.)

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

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

    Declaration

    Swift

    var allowsUndo: Bool

    Objective-C

    @property BOOL allowsUndo

    Discussion

    The value of this property is YEStrue if the cell handles undo operations itself or NOfalse if the app’s custom undo manager must handle undo behavior. Cell subclasses set the value of this property to indicate their preference for handling undo operations. For example, the NSTextFieldCell class uses sets this property to indicate it handles undo operations for edited text, and other controls set a value that is appropriate for their implementation. Do not change the value of this property otherwise.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • bezeled bezeled Property

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

    Declaration

    Swift

    var bezeled: Bool

    Objective-C

    @property(getter=isBezeled) BOOL bezeled

    Discussion

    The value of this property is YEStrue if the cell has a bezeled border or NOfalse if it does not. This property is mutually exclusive with the bordered property—that is, a cell’s border can be plain or bezeled but not both. Changing the value of this property automatically removes any border that has been set, regardless of the value you assign to the property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

    See Also

    bordered

  • bordered bordered Property

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

    Declaration

    Swift

    var bordered: Bool

    Objective-C

    @property(getter=isBordered) BOOL bordered

    Discussion

    The value of this property is YEStrue if the cell has a plain border or NOfalse if it does not. This property is mutually exclusive with the bezeled property—that is, a cell’s border can be plain or bezeled but not both. Changing the value of this property automatically removes any bezel that has been set, regardless of the value you assign to the property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

    See Also

    bezeled

  • opaque opaque Property

    A Boolean value indicating whether the cell is completely opaque. (read-only)

    Declaration

    Swift

    var opaque: Bool { get }

    Objective-C

    @property(getter=isOpaque, readonly) BOOL opaque

    Discussion

    The value of this property is YEStrue if the cell is completely opaque or NOfalse if it contains some transparency.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • The cell’s control tint.

    Declaration

    Swift

    var controlTint: NSControlTint

    Objective-C

    @property NSControlTint controlTint

    Discussion

    The default value of this property is NSDefaultControlTint.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The cell’s background style.

    Declaration

    Swift

    var backgroundStyle: NSBackgroundStyle

    Objective-C

    @property NSBackgroundStyle backgroundStyle

    Discussion

    The background describes the surface the cell is drawn onto in the drawWithFrame:inView: method. A control typically sets the value of this property before it asks the cell to draw. A cell may draw differently based on background characteristics. For example, a table view drawing a cell in a selected row might set the value to NSBackgroundStyleDark. A text cell might decide to render its text white as a result. A rating-style level indicator might draw its stars white instead of gray.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • The cel’s interior background style. (read-only)

    Declaration

    Swift

    var interiorBackgroundStyle: NSBackgroundStyle { get }

    Objective-C

    @property(readonly) NSBackgroundStyle interiorBackgroundStyle

    Discussion

    The interior background style describes the surface drawn onto in the drawInteriorWithFrame:inView: method. This is often the same as the backgroundStyle, but a button that draws a bezel would use a different value for this property.

    In a custom button with a custom bezel you can override this property and return a different value to describe that surface. A cell that has custom interior drawing might use the value of this property to pick an image that looks good on the cell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

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

    Declaration

    Swift

    var allowsMixedState: Bool

    Objective-C

    @property BOOL allowsMixedState

    Discussion

    When the value of this property is YEStrue, the cell supports three states: on, off, and mixed. When the value is NOfalse, the cell supports only the on and off states.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    nextState

  • nextState nextState Property

    The cell’s next state. (read-only)

    Declaration

    Swift

    var nextState: Int { get }

    Objective-C

    @property(readonly) NSInteger nextState

    Discussion

    If a cell has three states, it cycles in this order: on, off, mixed, on, off, and so forth. If the cell has only two states, it toggles between them.

    For a list of constants representing the possible cell states, see NSCellStateValue.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func setNextState()

    Objective-C

    - (void)setNextState

    Discussion

    If a cell has three states, it cycles in this order: on, off, mixed, on, off, and so forth. If the cell has only two states, it toggles between them.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • state state Property

    The cell’s current state.

    Declaration

    Swift

    var state: Int

    Objective-C

    @property NSInteger state

    Discussion

    The NSOffState state indicates the normal or unpressed state. The NSOnState state indicates the alternate or pressed state. The NSMixedState state indicates that the feature represented by the control is in effect somewhere.

    Although using the enumerated constants is preferred, you can also assign an integer value to this property. If the cell has two states, 0 is treated as NSOffState, and a nonzero value is treated as NSOnState. If the cell has three states, 0 is treated as NSOffState, a negative value is treated as NSMixedState, and a positive value is treated as NSOnState.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    allowsMixedState

  • editable editable Property

    A Boolean value indicating whether the cell is editable.

    Declaration

    Swift

    var editable: Bool

    Objective-C

    @property(getter=isEditable) BOOL editable

    Discussion

    When the value of this property is YEStrue, the cell is editable. When the value is YEStrue, the text of the cell is also made selectable. When you change the value of the property to NOfalse, the selectable property is restored to the value it had before the cell was made editable.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

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

    Declaration

    Swift

    var selectable: Bool

    Objective-C

    @property(getter=isSelectable) BOOL selectable

    Discussion

    When the value of this property is YEStrue, the cell’s text is selectable. Setting the value of this property to NOfalse also sets the editable property to NOfalse. If the value of this cell is YEStrue, the value in the editable property is not affected.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

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

    Declaration

    Swift

    var scrollable: Bool

    Objective-C

    @property(getter=isScrollable) BOOL scrollable

    Discussion

    When the value of this property is YEStrue, text can be scrolled past the cell’s bound. When the value is NOfalse, the cell wraps its text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • alignment alignment Property

    The alignment of the cell’s text.

    Declaration

    Swift

    var alignment: NSTextAlignment

    Objective-C

    @property NSTextAlignment alignment

    Discussion

    The default value of this property is NSNaturalTextAlignment. For a list of possible text alignments, see NSTextAlignment.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    wraps

  • font font Property

    The font that the cell uses to display text.

    Declaration

    Swift

    var font: NSFont?

    Objective-C

    @property(strong) NSFont *font

    Discussion

    The value of this property is nil if the cell is not a text-type cell. Assigning a new font object to this property converts the cell to a text-type cell if it is not already one.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var lineBreakMode: NSLineBreakMode

    Objective-C

    @property NSLineBreakMode lineBreakMode

    Discussion

    The value in this property can also be modified when you change the value of the wraps property. For a list of supported line break modes, see NSLineBreakMode.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

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

    Declaration

    Swift

    var truncatesLastVisibleLine: Bool

    Objective-C

    @property BOOL truncatesLastVisibleLine

    Discussion

    When the value of this property is YEStrue, the cell truncates text and adds an ellipsis character to the last visible line when the text does not fit. The value in the lineBreakMode property must be NSLineBreakByWordWrapping or NSLineBreakByCharWrapping for this option to have any effect.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    See Also

    lineBreakMode

  • wraps wraps Property

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

    Declaration

    Swift

    var wraps: Bool

    Objective-C

    @property BOOL wraps

    Discussion

    When the value of this property is YEStrue, the cell wraps text and makes the cell non-scrollable. If the text of the cell is an attributed string value, you must explicitly set the paragraph style line break mode. Setting the value of this property to YEStrue is equivalent to setting the lineBreakMode property to NSLineBreakByWordWrapping.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    lineBreakMode

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

    Declaration

    Swift

    var baseWritingDirection: NSWritingDirection

    Objective-C

    @property NSWritingDirection baseWritingDirection

    Discussion

    The default value of this property is NSWritingDirectionNatural. The Text system uses this value as a hint for calculating the actual direction for displaying Unicode characters. If you know the base writing direction of the text you are rendering, you can set the value of this property to the correct direction to help the text system.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The cell’s value as an attributed string.

    Declaration

    Swift

    @NSCopying var attributedStringValue: NSAttributedString

    Objective-C

    @property(copy) NSAttributedString *attributedStringValue

    Discussion

    Use this property to get the value of the cell interpreted as an attributed string. The textual attributes included in the string are the default paragraph style, the cell’s font and alignment, and whether the cell is enabled and scrollable.

    When setting the value of this property, if the cell has a formatter, but the formatter does not understand the attributed string, the formatter marks the cell’s object as invalid. If the receiver is not a text-type cell, it is converted to one before the value is set.

    If you use a class that has an attributedStringValue property, the cell gets the string from that property instead of using the stringValue property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var allowsEditingTextAttributes: Bool

    Objective-C

    @property BOOL allowsEditingTextAttributes

    Discussion

    When the value of this property is YEStrue, the user can modify the font and other textual attributes of the cell. When the value is NOfalse, the user cannot edit the text or import graphics, which effectively means the cell cannot support RTFD text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    importsGraphics

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

    Declaration

    Swift

    var importsGraphics: Bool

    Objective-C

    @property BOOL importsGraphics

    Discussion

    When the value of this property is YEStrue, the cell can import images into its text and support the RTFD text format.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func setUpFieldEditorAttributes(_ textObj: NSText) -> NSText

    Objective-C

    - (NSText *)setUpFieldEditorAttributes:(NSText *)textObj

    Parameters

    textObj

    The field editor to configure. .

    Return Value

    The configured field editor.

    Discussion

    If the receiver is disabled, this method sets the text color to dark gray; otherwise the method sets it to the default color. If the receiver has a bezeled border, this method sets the background to the default color for text backgrounds; otherwise, the method sets it to the color of the receiver’s NSControl object.

    You should not use this method to substitute a new field editor. setUpFieldEditorAttributes: is intended to modify the attributes of the text object (that is, the field editor) passed into it and return that text object. If you want to substitute your own field editor, use the fieldEditor:forObject: method or the windowWillReturnFieldEditor:toObject: delegate method of NSWindow.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • title title Property

    The cell’s title text.

    Declaration

    Swift

    var title: String

    Objective-C

    @property(copy) NSString *title

    Discussion

    This property contains the string to display in the cell. Subclasses (such as NSButtonCell) may use the title for a different purpose.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • action action Property

    The action performed by the cell.

    Declaration

    Swift

    var action: Selector

    Objective-C

    @property SEL action

    Discussion

    The value of this property is the selector to call on the cell’s target object. Set the value of this property to nil to stop the delivery of action messages.

    The default value of this property is nil. Setting the value of this property raises with NSInternalInconsistencyException. Subclasses are expected to override this property as part of their target/action implementation.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    target

  • target target Property

    The object that receives the cell’s action messages.

    Declaration

    Swift

    weak var target: AnyObject?

    Objective-C

    @property(weak) id target

    Discussion

    The value of this property is the object that implements the selector specified by the action property. Set the value of this property to nil to stop the delivery of action messages.

    The default value of this property is nil. Setting the value of this property raises with NSInternalInconsistencyException. Subclasses are expected to override this property as part of their target/action implementation.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var continuous: Bool

    Objective-C

    @property(getter=isContinuous) BOOL continuous

    Discussion

    When the value of this property is YES, the cell’s action message is sent continuously during mouse tracking. In practice, the continuous delivery of action messages has meaning only for NSActionCell and its subclasses, which implement the target/action mechanism. Some NSControl subclasses, notably NSMatrix, send a default action to a default target when a cell doesn’t provide a target or action.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

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

    Declaration

    Swift

    func sendActionOn(_ mask: Int) -> Int

    Objective-C

    - (NSInteger)sendActionOn:(NSInteger)mask

    Parameters

    mask

    A bit mask containing the conditions for sending the action. The only conditions that are actually checked are associated with the NSLeftMouseDownMask, NSLeftMouseUpMask, NSLeftMouseDraggedMask, and NSPeriodicMask bits.

    Return Value

    A bit mask containing the previous settings. This bit mask uses the same values as specified in the mask parameter.

    Discussion

    You use this method during mouse tracking when the mouse button changes state, the mouse moves, or if the cell is marked to send its action continuously while tracking. Because of this, the only bits checked in mask are NSLeftMouseDownMask, NSLeftMouseUpMask, NSLeftMouseDraggedMask, and NSPeriodicMask, which are declared in the NSEvent class reference.

    You can use the continuous property to turn on the flag corresponding to NSPeriodicMask or NSLeftMouseDraggedMask, whichever is appropriate to the given subclass of NSCell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    action

  • image image Property

    The image displayed by the cell, if any.

    Declaration

    Swift

    var image: NSImage?

    Objective-C

    @property(strong) NSImage *image

    Discussion

    Setting the value of this property converts the cell to an image-type cell, if it is not one already. The value of this property is nil if the cell is not an image-type cell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    type

  • tag tag Property

    A tag for identifying the cell.

    Declaration

    Swift

    var tag: Int

    Objective-C

    @property NSInteger tag

    Discussion

    Tags allow you to identify particular cells. Tag values are not used internally by AppKit. You typically set tag values in Interface Builder and use them at runtime in your application. When you set the tag of a control with a single cell in Interface Builder, it sets the tags of both the control and the cell to the same value as a convenience.

    The default value of this property is -1. Setting the value of this property raises with NSInternalInconsistencyException. Subclasses are expected to override this property if they support tags. The NSActionCell class implements this property and stores the integer you specify.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • formatter formatter Property

    The cell’s formatter object.

    Declaration

    Swift

    var formatter: AnyObject?

    Objective-C

    @property(strong) id formatter

    Discussion

    A formatter handles the translation of the receiver’s contents between its onscreen representation and its object value. Cells use a formatter object to format the textual representation of their object value and to validate cell input and convert that input to an object value. When assigning a new formatter to a cell, the formatter attempts to interpret the cell’s current value. If it cannot do so, the formatter converts the current value to a string object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the default menu for instances of the cell.

    Declaration

    Swift

    class func defaultMenu() -> NSMenu?

    Objective-C

    + (NSMenu *)defaultMenu

    Return Value

    The default menu. The NSCell implementation of this method returns nil.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    menu

  • menu menu Property

    The cell’s contextual menu.

    Declaration

    Swift

    var menu: NSMenu?

    Objective-C

    @property(strong) NSMenu *menu

    Discussion

    Use this property to specify a menu containing contextual commands associated with the cell. If the cell does not have a menu, set this property to nil.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func menuForEvent(_ anEvent: NSEvent, inRect cellFrame: NSRect, ofView aView: NSView) -> NSMenu?

    Objective-C

    - (NSMenu *)menuForEvent:(NSEvent *)anEvent inRect:(NSRect)cellFrame ofView:(NSView *)aView

    Parameters

    anEvent

    The event used to find the menu.

    cellFrame

    The cell's rectangle. This rectangle indicates the region containing the cursor.

    aView

    The view that manages the cell. This is usually the control object that owns the cell.

    Return Value

    The menu associated with the cell and event parameters, or nil if no menu is set.

    Discussion

    This method is usually invoked by the NSControl object (aView) managing the receiver. The default implementation gets the value of the menu property and returns nil if no menu has been set. Subclasses can override to customize the returned menu according to the event received and the area in which the mouse event occurs.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func compare(_ otherCell: AnyObject) -> NSComparisonResult

    Objective-C

    - (NSComparisonResult)compare:(id)otherCell

    Parameters

    otherCell

    The cell to compare against the receiver. This parameter must be of type NSCell; if it is not, this method raises NSBadComparisonException.

    This value must not be nil. If the value is nil, the behavior is undefined and may change in future versions of OS X.

    Return Value

    NSOrderedAscending if the string value of the receiver precedes the string value of otherCell in lexical ordering, NSOrderedSame if the string values are equivalent in lexical value, and NSOrderedDescending string value of the receiver follows the string value of otherCell in lexical ordering.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value indicating whether the cell accepts first responder status. (read-only)

    Declaration

    Swift

    var acceptsFirstResponder: Bool { get }

    Objective-C

    @property(readonly) BOOL acceptsFirstResponder

    Discussion

    When the value of this property is YEStrue, the cell is able to become the first responder. The default value of this property is YEStrue when the cell is enabled. Subclasses may override this method to return a different value.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var showsFirstResponder: Bool

    Objective-C

    @property BOOL showsFirstResponder

    Discussion

    When the value of this property is YEStrue and the cell becomes the first responder, the cell performs additional drawing to indicate that it is the first responder. The NSCell class itself does not draw a first-responder indicator. Subclasses may use the value in this property to determine whether or not they should draw one.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var refusesFirstResponder: Bool

    Objective-C

    @property BOOL refusesFirstResponder

    Discussion

    Set the value of this property to YEStrue to prevent the cell from becoming the first responder. To determine whether the cell can become first responder right now, get the value of the acceptsFirstResponder property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Simulates a single mouse click on the receiver.

    Declaration

    Swift

    func performClick(_ sender: AnyObject?)

    Objective-C

    - (void)performClick:(id)sender

    Parameters

    sender

    The object to use as the sender of the event (if the receiver's control view is not valid). This object must be a subclass of NSView.

    Discussion

    This method performs the receiver's action on its target. The receiver must be enabled to perform the action. If the receiver's control view is valid, that view is used as the sender; otherwise, the value in sender is used.

    The receiver of this message must be a cell of type NSActionCell. This method raises an exception if the action message cannot be successfully sent.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    controlView

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

    Declaration

    Swift

    func takeObjectValueFrom(_ sender: AnyObject?)

    Objective-C

    - (void)takeObjectValueFrom:(id)sender

    Parameters

    sender

    The object from which to take the value. This object must support the objectValue property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    objectValue

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

    Declaration

    Swift

    func takeIntegerValueFrom(_ sender: AnyObject?)

    Objective-C

    - (void)takeIntegerValueFrom:(id)sender

    Parameters

    sender

    The object from which to take the value. This object must implement the integerValue property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    See Also

    integerValue

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

    Declaration

    Swift

    func takeIntValueFrom(_ sender: AnyObject?)

    Objective-C

    - (void)takeIntValueFrom:(id)sender

    Parameters

    sender

    The object from which to take the value. This object must implement the intValue property.

    Discussion

    Use the takeIntegerValueFrom: method instead.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func takeStringValueFrom(_ sender: AnyObject?)

    Objective-C

    - (void)takeStringValueFrom:(id)sender

    Parameters

    sender

    The object from which to take the value. This object must implement the stringValue property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    stringValue

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

    Declaration

    Swift

    func takeDoubleValueFrom(_ sender: AnyObject?)

    Objective-C

    - (void)takeDoubleValueFrom:(id)sender

    Parameters

    sender

    The object from which to take the value. This object must implement the doubleValue property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    doubleValue

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

    Declaration

    Swift

    func takeFloatValueFrom(_ sender: AnyObject?)

    Objective-C

    - (void)takeFloatValueFrom:(id)sender

    Parameters

    sender

    The object from which to take the value. This object must implement the floatValue property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    floatValue

  • The object represented by the cell.

    Declaration

    Swift

    var representedObject: AnyObject?

    Objective-C

    @property(strong) id representedObject

    Discussion

    Use this property to link the cell an appropriate object. For example, in a pop-up list of color names, the represented object of each cell could be the appropriate NSColor object.

    Special Considerations

    When you copy an NSCell object, the value of this property is set to nil in the copy.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    objectValue

  • Initiates the mouse tracking behavior in a cell.

    Declaration

    Swift

    func trackMouse(_ theEvent: NSEvent, inRect cellFrame: NSRect, ofView controlView: NSView, untilMouseUp untilMouseUp: Bool) -> Bool

    Objective-C

    - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp

    Parameters

    theEvent

    The event that caused the mouse tracking to occur.

    cellFrame

    The receiver's frame rectangle.

    controlView

    The view containing the receiver. This is usually an NSControl object.

    untilMouseUp

    If YEStrue, mouse tracking continues until the user releases the mouse button. If NOfalse, tracking continues until the cursor leaves the tracking rectangle, specified by the cellFrame parameter, regardless of the mouse button state. See the discussion for more information.

    Return Value

    YEStrue if the mouse tracking conditions are met, otherwise NOfalse.

    Discussion

    This method is generally not overridden because the default implementation invokes other NSCell methods that can be overridden to handle specific events in a dragging session. This method’s return value depends on the untilMouseUp flag. If untilMouseUp is set to YEStrue, this method returns YEStrue if the mouse button goes up while the cursor is anywhere; NOfalse, otherwise. If untilMouseUp is set to NOfalse, this method returns YEStrue if the mouse button goes up while the cursor is within cellFrame; NOfalse, otherwise.

    This method first invokes startTrackingAt:inView:. If that method returns YEStrue, then as mouse-dragged events are intercepted, continueTracking:at:inView: is invoked until either the method returns NOfalse or the mouse is released. Finally, stopTracking:at:inView:mouseIsUp: is invoked if the mouse is released. If untilMouseUp is YEStrue, it’s invoked when the mouse button goes up while the cursor is anywhere. If untilMouseUp is NOfalse, it’s invoked when the mouse button goes up while the cursor is within cellFrame. You usually override one or more of these methods to respond to specific mouse events.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Begins tracking mouse events within the receiver.

    Declaration

    Swift

    func startTrackingAt(_ startPoint: NSPoint, inView controlView: NSView) -> Bool

    Objective-C

    - (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView

    Parameters

    startPoint

    The initial location of the cursor.

    controlView

    The NSControl object managing the receiver.

    Return Value

    YEStrue if the receiver is set to respond continuously or set to respond when the mouse is dragged, otherwise NOfalse.

    Discussion

    The NSCell implementation of trackMouse:inRect:ofView:untilMouseUp: invokes this method when tracking begins. Subclasses can override this method to implement special mouse-tracking behavior at the beginning of mouse tracking—for example, displaying a special cursor.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func continueTracking(_ lastPoint: NSPoint, at currentPoint: NSPoint, inView controlView: NSView) -> Bool

    Objective-C

    - (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView

    Parameters

    lastPoint

    Contains either the initial location of the cursor when tracking began or the previous current point.

    currentPoint

    The current location of the cursor.

    controlView

    The NSControl object managing the receiver.

    Return Value

    YEStrue if mouse tracking should continue, otherwise NOfalse.

    Discussion

    This method is invoked in trackMouse:inRect:ofView:untilMouseUp:. The default implementation returns YEStrue if the cell is set to continuously send action messages to its target when the mouse button is down or the mouse is being dragged. Subclasses can override this method to provide more sophisticated tracking behavior.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Stops tracking mouse events within the receiver.

    Declaration

    Swift

    func stopTracking(_ lastPoint: NSPoint, at stopPoint: NSPoint, inView controlView: NSView, mouseIsUp flag: Bool)

    Objective-C

    - (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag

    Parameters

    lastPoint

    Contains the previous position of the cursor.

    stopPoint

    The current location of the cursor.

    controlView

    The NSControl object managing the receiver.

    flag

    If YEStrue, this method was invoked because the user released the mouse button; otherwise, if NOfalse, the cursor left the designated tracking rectangle.

    Discussion

    The default NSCell implementation of trackMouse:inRect:ofView:untilMouseUp: invokes this method when the cursor has left the bounds of the receiver or the mouse button goes up. The default NSCell implementation of this method does nothing. Subclasses often override this method to provide customized tracking behavior. The following example increments the state of a tristate cell when the mouse button is clicked:

    • - (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint
    • inView:(NSView *)controlView mouseIsUp:(BOOL)flag
    • {
    • if (flag == YES) {
    • [self setTriState:([self triState]+1)];
    • }
    • }

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var mouseDownFlags: Int { get }

    Objective-C

    @property(readonly) NSInteger mouseDownFlags

    Discussion

    The value of this property is the value of the modifier flags from the most recent NSEvent object representing a mouse-down event. If tracking has not yet occurred or the event contained no modifier keys, the value of this property is 0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    modifierFlags (NSEvent)

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

    Declaration

    Swift

    class func prefersTrackingUntilMouseUp() -> Bool

    Objective-C

    + (BOOL)prefersTrackingUntilMouseUp

    Return Value

    YEStrue if tracking stops when the cursor leaves the cell, otherwise NOfalse.

    Discussion

    The default implementation returns NOfalse. Subclasses may override this method to return a different value.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func getPeriodicDelay(_ delay: UnsafeMutablePointer<Float>, interval interval: UnsafeMutablePointer<Float>)

    Objective-C

    - (void)getPeriodicDelay:(float *)delay interval:(float *)interval

    Parameters

    delay

    On input, a pointer to a floating-point variable. On output, the variable contains the current delay (measured in seconds) before messages are sent. This parameter must not be NULL.

    interval

    On input, a pointer to a floating point variable. On output, the variable contains the interval (measured in seconds) at which messages are sent. This parameter must not be NULL.

    Discussion

    The default implementation returns a delay of 0.2 and an interval of 0.025 seconds. Subclasses can override this method to supply their own delay and interval values.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    continuous

  • Returns hit testing information for the receiver.

    Declaration

    Swift

    func hitTestForEvent(_ event: NSEvent, inRect cellFrame: NSRect, ofView controlView: NSView) -> NSCellHitResult

    Objective-C

    - (NSCellHitResult)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView

    Parameters

    event

    The current event.

    cellFrame

    The cell’s frame.

    controlView

    The control object in which the cell is located.

    Return Value

    A constant that specifies the type of area in which the event occurred—see Hit Testing for values.

    Discussion

    You can use a bit-wise mask to look for a specific value when calling this method—see Hit Testing for values.

    Generally, this method should be overridden by custom NSCell subclasses to return the correct result. Currently, it is called by some multi-cell views, such as NSTableView.

    By default, NSCell looks at the cell type and does the following:

    • NSImageCellType: If the image exists and the event point is in the image returns NSCellHitContentArea, otherwise NSCellHitNone.

    • NSTextCellType (also applies to NSTextFieldCell):

      If there is text: If the event point hits in the text, return NSCellHitContentArea. Additionally, if the cell is enabled return NSCellHitContentArea | NSCellHitEditableTextArea.

      If there is not text: return NSCellHitNone.

    • NSNullCellType (this is the default that applies to non text or image cells who don't override hitTestForEvent:inRect:ofView:):

      Return NSCellHitContentArea by default;

      If the cell not disabled, and it would track, return NSCellHitContentArea | NSCellHitTrackableArea.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

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

    Declaration

    Swift

    func resetCursorRect(_ cellFrame: NSRect, inView controlView: NSView)

    Objective-C

    - (void)resetCursorRect:(NSRect)cellFrame inView:(NSView *)controlView

    Parameters

    cellFrame

    The rectangle in which to display the I-beam cursor.

    controlView

    The control that manages the cell.

    Discussion

    The receiver must be an enabled and selectable (or editable) text-type cell.

    This method is invoked by resetCursorRects and in general you do not need to call this method unless you have a custom NSView that uses a cell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The key equivalent associated with clicking the cell. (read-only)

    Declaration

    Swift

    var keyEquivalent: String { get }

    Objective-C

    @property(readonly, copy) NSString *keyEquivalent

    Discussion

    Subclasses can override this property and return a string with a valid character for the key equivalent. The default implementation of this property returns an empty string.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func draggingImageComponentsWithFrame(_ frame: NSRect, inView view: NSView) -> [AnyObject]

    Objective-C

    - (NSArray *)draggingImageComponentsWithFrame:(NSRect)frame inView:(NSView *)view

    Parameters

    frame

    The bounding rectangle of the receiver.

    view

    The view that manages the cell.

    Return Value

    An array of NSDraggingImageComponent objects representing the cell.

    Discussion

    The default implementation generates an image from the cell and return two components: one for NSDraggingImageComponentLabelKey and another for NSDraggingImageComponentIconKey. This is done by capturing the portion from the titleRectForBounds: and imageRectForBounds: methods respectively.

    This method can be subclassed and overridden to provide a custom set of NSDraggingImageComponent to create the drag image for the cell. This method is generally used by NSTableView/NSOutlineView.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • Draws the focus ring for the control.

    Declaration

    Swift

    func drawFocusRingMaskWithFrame(_ cellFrame: NSRect, inView controlView: NSView)

    Objective-C

    - (void)drawFocusRingMaskWithFrame:(NSRect)cellFrame inView:(NSView *)controlView

    Parameters

    cellFrame

    The bounding rectangle of the receiver, or a portion of the bounding rectangle.

    controlView

    The view that manages the cell.

    Discussion

    Implemented by NSCell subclasses to draw the appropriate focus ring for the control The default implementation does nothing.

    The Application Kit automatically invokes this method when appropriate, to render the view's focus ring. The view must be eligible to become its window's firstResponder, by overriding acceptsFirstResponder returning YEStrue.

    The focus ring is rendered using the style specified by the focusRingType property, which must not be NSFocusRingTypeNone unless you want to suppress drawing of the focus ring. An implementation of drawFocusRingMaskWithFrame:inView: can assume that it is drawing in the view's bounds, and that the fill and stroke colors have been set to an arbitrary fully opaque color. It needs only draw the desired focus ring shape or an image or other object whose outline defines the focus ring mask.

    This new OS X v10.7 focus ring API should no longer call NSSetFocusRingStyle() and perform it's own drawing.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • Returns the bounds of the focus ring mask.

    Declaration

    Swift

    func focusRingMaskBoundsForFrame(_ cellFrame: NSRect, inView controlView: NSView) -> NSRect

    Objective-C

    - (NSRect)focusRingMaskBoundsForFrame:(NSRect)cellFrame inView:(NSView *)controlView

    Parameters

    cellFrame

    The bounding rectangle of the receiver, or a portion of the bounding rectangle.

    controlView

    The view that manages the cell.

    Return Value

    Returns a rectangle encompassing the focus ring bounds in the controlView coordinate space.

    Discussion

    Implemented by NSCell subclasses to allow the cell to provide the rectangular bounds of the focus ring mask for the cell.

    The default implementation returns an empty value. Subclasses are expected to implement this method if they intend to draw a focus ring.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • Returns the default type of focus ring for the receiver.

    Declaration

    Swift

    class func defaultFocusRingType() -> NSFocusRingType

    Objective-C

    + (NSFocusRingType)defaultFocusRingType

    Return Value

    The default type of focus ring for the receiver (one of the values listed in NSFocusRingType).

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

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

    Declaration

    Swift

    var focusRingType: NSFocusRingType

    Objective-C

    @property NSFocusRingType focusRingType

    Discussion

    You can disable a view's focus ring drawing by setting this property to NSFocusRingTypeNone. The only times you should disable focus ring drawing are when you want to draw your own focus ring or when there is insufficient space to display a focus ring in the default location.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Recalculates the cell geometry.

    Declaration

    Swift

    func calcDrawInfo(_ aRect: NSRect)

    Objective-C

    - (void)calcDrawInfo:(NSRect)aRect

    Parameters

    aRect

    The reference rectangle to use when calculating the cell information.

    Discussion

    Objects (such as controls) that manage NSCell objects generally maintain a flag that informs them if any of their cells have been modified in such a way that the location or size of the cell should be recomputed. If so, calcSize method of NSControl is automatically invoked prior to the display of the cell, and that method invokes the calcDrawInfo: method of the cell.

    The default implementation of this method does nothing.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • cellSize cellSize Property

    The minimum size needed to display the cell. (read-only)

    Declaration

    Swift

    var cellSize: NSSize { get }

    Objective-C

    @property(readonly) NSSize cellSize

    Discussion

    This property contains the smallest cell size (in points) required to draw its contents. If the cell is not a text or image cell, the cell size is set to (10000, 10000). If an image cell does not yet have an associated image, the cell size is NSZeroSize.This method takes into account of the size of the image or text in the cell along with any margin areas required by the cell’s border, if any.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func cellSizeForBounds(_ aRect: NSRect) -> NSSize

    Objective-C

    - (NSSize)cellSizeForBounds:(NSRect)aRect

    Parameters

    aRect

    The size of the cell, or the size of the aRect parameter if the cell is not a text or image cell. If the cell is an image cell but no image has been set, returns NSZeroSize.

    Discussion

    This method takes into account of the size of the image or text within a certain offset determined by the border type of the cell. If the receiver is of text type, the text is resized to fit within aRect (as much as aRect is within the bounds of the cell).

    To support constraint-based layout, when the content of a custom cell changes in such a way that the return value of this method would change, the cell needs to notify its control of the change by calling the control’s invalidateIntrinsicContentSizeForCell: method.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the rectangle within which the receiver draws itself

    Declaration

    Swift

    func drawingRectForBounds(_ theRect: NSRect) -> NSRect

    Objective-C

    - (NSRect)drawingRectForBounds:(NSRect)theRect

    Parameters

    theRect

    The bounding rectangle of the receiver.

    Return Value

    The rectangle in which the receiver draws itself. This rectangle is slightly inset from the one in theRect.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    calcSize (NSControl)

  • Returns the rectangle in which the receiver draws its image.

    Declaration

    Swift

    func imageRectForBounds(_ theRect: NSRect) -> NSRect

    Objective-C

    - (NSRect)imageRectForBounds:(NSRect)theRect

    Parameters

    theRect

    The bounding rectangle of the receiver.

    Return Value

    The rectangle in which the receiver draws its image. This rectangle is slightly offset from the one in theRect.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func titleRectForBounds(_ theRect: NSRect) -> NSRect

    Objective-C

    - (NSRect)titleRectForBounds:(NSRect)theRect

    Parameters

    theRect

    The bounding rectangle of the receiver.

    Return Value

    The rectangle in which the receiver draws its title text.

    Discussion

    If the receiver is a text-type cell, this method resizes the drawing rectangle for the title (theRect) inward by a small offset to accommodate the cell border. If the receiver is not a text-type cell, the method does nothing.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The size of the cell.

    Declaration

    Swift

    var controlSize: NSControlSize

    Objective-C

    @property NSControlSize controlSize

    Discussion

    Use this property to change the rendered size of the cell and its control. For a list of possible values, see NSControlSize.

    Changing the cell’s control size does not change the font used by the cell. Use the systemFontSizeForControlSize: class method of NSFont to obtain an appropriate font based on the new control size.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func drawWithFrame(_ cellFrame: NSRect, inView controlView: NSView)

    Objective-C

    - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView

    Parameters

    cellFrame

    The bounding rectangle of the receiver.

    controlView

    The control that manages the cell.

    Discussion

    This method draws the cell in the currently focused view, which can be different from the controlView passed in. Taking advantage of this behavior is not recommended, however.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func highlightColorWithFrame(_ cellFrame: NSRect, inView controlView: NSView) -> NSColor

    Objective-C

    - (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView

    Parameters

    cellFrame

    The bounding rectangle of the receiver.

    controlView

    The control that manages the cell.

    Return Value

    The color the receiver uses when drawing the selection highlight.

    Discussion

    You should not assume that a cell would necessarily want to draw itself with the value returned from selectedControlColor. A cell may wish to draw with different a selection highlight color depending on such things as the key state of its controlView.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.1 and later.

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

    Declaration

    Swift

    func drawInteriorWithFrame(_ cellFrame: NSRect, inView controlView: NSView)

    Objective-C

    - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView

    Parameters

    cellFrame

    The bounding rectangle of the receiver, or a portion of the bounding rectangle.

    controlView

    The control that manages the cell.

    Discussion

    Text-type NSCell objects display their contents in a rectangle slightly inset from cellFrame using a global NSText object. Image-type NSCell objects display their contents centered within cellFrame. If the proper attributes are set, this method also displays the dotted-line rectangle to indicate if the control is the first responder and highlights the cell. This method is invoked from the drawCellInside: method of NSControl to visually update what the cell displays when its contents change. The drawing done by the NSCell implementation is minimal and becomes more complex in objects such as NSButtonCell and NSSliderCell.

    This method draws the cell in the currently focused view, which can be different from the controlView passed in. Taking advantage of this is not recommended.

    Subclasses often override this method to provide more sophisticated drawing of cell contents. Because drawWithFrame:inView: invokes drawInteriorWithFrame:inView: after it draws the cell's border, do not invoke drawWithFrame:inView: in your override implementation.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The view associated with the cell.

    Declaration

    Swift

    unowned(unsafe) var controlView: NSView?

    Objective-C

    @property(assign) NSView *controlView

    Discussion

    This property contains the view associated with the cell. This view is normally an NSControl object. The default value of this property is nil.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Redraws the receiver with the specified highlight setting.

    Declaration

    Swift

    func highlight(_ flag: Bool, withFrame cellFrame: NSRect, inView controlView: NSView)

    Objective-C

    - (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView:(NSView *)controlView

    Parameters

    flag

    If YEStrue, the cell is redrawn with a highlight; otherwise, if NOfalse, the highlight is removed.

    cellFrame

    The bounding rectangle of the receiver.

    controlView

    The control that manages the cell.

    Discussion

    Note that the NSCell highlighting does not appear when highlighted cells are printed (although instances of NSTextFieldCell, NSButtonCell, and others can print themselves highlighted). Generally, you cannot depend on highlighting being printed because implementations of this method may choose (or not choose) to use transparency.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var highlighted: Bool

    Objective-C

    @property(getter=isHighlighted) BOOL highlighted

    Discussion

    When the value of this property is YEStrue, the cell draws itself with a highlighted appearance. The default value of this property is NOfalse.

    Assigning a new value to this property has no effect by default. Subclasses can override the property to provide a highlighting behavior. For example, the NSButtonCell class overrides this property, so that when the value is YEStrue the button draws the button with a highlight appearance specified by NSCellLightsByBackground, NSCellLightsByContents, or NSCellLightsByGray.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

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

    Declaration

    Swift

    func editWithFrame(_ aRect: NSRect, inView controlView: NSView, editor textObj: NSText, delegate anObject: AnyObject?, event theEvent: NSEvent)

    Objective-C

    - (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent

    Parameters

    aRect

    The bounding rectangle of the cell.

    controlView

    The control that manages the cell.

    textObj

    The field editor to use for editing the cell.

    anObject

    The object to use as a delegate for the field editor (textObj parameter). This delegate object receives various NSText delegation and notification methods during the course of editing the cell's contents.

    theEvent

    The NSLeftMouseDown event that initiated the editing behavior.

    Discussion

    If the receiver isn’t a text-type NSCell object, no editing is performed. Otherwise, the field editor (textObj) is sized to aRect and its superview is set to controlView, so it exactly covers the receiver. The field editor is then activated and editing begins. It’s the responsibility of the delegate to end editing when responding to textShouldEndEditing:. Upon ending the editing session, the delegate should remove any data from the field editor.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func selectWithFrame(_ aRect: NSRect, inView controlView: NSView, editor textObj: NSText, delegate anObject: AnyObject?, start selStart: Int, length selLength: Int)

    Objective-C

    - (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength

    Parameters

    aRect

    The bounding rectangle of the cell.

    controlView

    The control that manages the cell.

    textObj

    The field editor to use for editing the cell.

    anObject

    The object to use as a delegate for the field editor (textObj parameter). This delegate object receives various NSText delegation and notification methods during the course of editing the cell's contents.

    selStart

    The start of the text selection.

    selLength

    The length of the text range.

    Discussion

    This method is similar to editWithFrame:inView:editor:delegate:event:, except that it can be invoked in any situation, not only on a mouse-down event. This method returns without doing anything if controlView, textObj, or the receiver is nil, or if the receiver has no font set for it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var sendsActionOnEndEditing: Bool

    Objective-C

    @property BOOL sendsActionOnEndEditing

    Discussion

    When the value of this property is YEStrue, the control sends its action message when editing is complete. Editing is complete when the user does one of the following:

    • Presses the Return key

    • Presses the Tab key to move out of the field

    • Clicks another text field

    When the value is NOfalse, the control sends its action message only when the user presses the Return key.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func endEditing(_ textObj: NSText)

    Objective-C

    - (void)endEditing:(NSText *)textObj

    Parameters

    textObj

    The field editor currently handling the editing of the cell's content.

    Discussion

    Ends any editing of text that began with a call to editWithFrame:inView:editor:delegate:event: or selectWithFrame:inView:editor:delegate:start:length:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value indicating whether the cell’s field editor should post text change notifications. (read-only)

    Declaration

    Swift

    var wantsNotificationForMarkedText: Bool { get }

    Objective-C

    @property(readonly) BOOL wantsNotificationForMarkedText

    Discussion

    When the value of this property is YEStrue, the field editor should post text notification changes while editing marked text. When the value is NO, the field editor should delay notifications until the marked text is confirmed.

    The default value of this property is NOfalse. Subclasses can override the property and change the value as appropriate.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns a custom field editor for editing in the view.

    Declaration

    Swift

    func fieldEditorForView(_ aControlView: NSView) -> NSTextView?

    Objective-C

    - (NSTextView *)fieldEditorForView:(NSView *)aControlView

    Parameters

    aControlView

    The view containing cells that require a custom field editor.

    Return Value

    A custom field editor. The field editor must have isFieldEditor set to YEStrue.

    Discussion

    This is an override point for NSCell subclasses designed to use their own custom field editors. This message is sent to the selected cell of aControlView using the NSWindow method in fieldEditor:forObject:.

    Returning non-nil from this method indicates skipping the standard field editor querying processes including windowWillReturnFieldEditor:toObject: delegation.

    The default implementation returns nil.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    var usesSingleLineMode: Bool

    Objective-C

    @property BOOL usesSingleLineMode

    Discussion

    When the value of this property is YEStrue, text layout and rendering is restricted to a single line. In addition, the cell ignores the return value from wraps, interprets NSLineBreakByWordWrapping and NSLineBreakByCharWrapping returned by lineBreakMode as NSLineBreakByClipping, and configures the field editor to ignore key binding commands that insert paragraph and line separators.

    The field editor bound to a single-line cell filters out paragraph and line separator insertion from user actions. Cells in single-line mode use the fixed baseline layout. The text baseline position is determined solely by the control size regardless of content font style or size.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns the expansion cell frame for the receiver.

    Declaration

    Swift

    func expansionFrameWithFrame(_ cellFrame: NSRect, inView view: NSView) -> NSRect

    Objective-C

    - (NSRect)expansionFrameWithFrame:(NSRect)cellFrame inView:(NSView *)view

    Parameters

    cellFrame

    The frame for the receiver.

    view

    The view in which the receiver will be drawn.

    Return Value

    The expansion cell frame for the receiver. If the frame is not too small, return an empty rect (NSZeroRect), and no expansion tool tip view will be shown.

    Discussion

    This method allows the cell to return an expansion cell frame if cellFrame is too small for the entire contents in the view. When the mouse is hovered over the cell in certain controls, the full cell contents are shown in a special floating tool tip view. By default, NSCell returns NSZeroRect, while some subclasses (such as NSTextFieldCell) will return the proper frame when required.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Instructs the receiver to draw in an expansion frame.

    Declaration

    Swift

    func drawWithExpansionFrame(_ cellFrame: NSRect, inView view: NSView)

    Objective-C

    - (void)drawWithExpansionFrame:(NSRect)cellFrame inView:(NSView *)view

    Parameters

    cellFrame

    The frame in which to draw.

    view

    The view in which to draw. This view may be different from the original view that the cell appeared in.

    Discussion

    This method allows the cell to perform custom expansion tool tip drawing. By default, NSCell simply calls drawWithFrame:inView:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • The layout direction of the user interface.

    Declaration

    Swift

    var userInterfaceLayoutDirection: NSUserInterfaceLayoutDirection

    Objective-C

    @property NSUserInterfaceLayoutDirection userInterfaceLayoutDirection

    Discussion

    This property specifies the general user interface layout flow directions. For subclasses that have multiple visual components in a single cell instance, this property should specify the directionality or flow of components.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

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

    Deprecation Statement

    Use a formatter instead. See formatter.

    Declaration

    Objective-C

    - (void)setEntryType:(NSInteger)aType

    Parameters

    aType

    One of the types listed for this method in Data Entry Types.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.0.

  • entryType - entryType (OS X v10.0)

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

    Deprecation Statement

    Use a formatter instead. See formatter.

    Declaration

    Objective-C

    - (NSInteger)entryType

    Return Value

    One of the types listed for this method in Data Entry Types. If the receiver is not a text-type cell, or if no type has been set, NSAnyType is returned.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.0.

  • isEntryAcceptable: - isEntryAcceptable: Deprecated in OS X v 10.0 and later

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

    Deprecation Statement

    Use NSFormatter instead.

    Declaration

    Objective-C

    - (BOOL)isEntryAcceptable:(NSString *)aString

    Parameters

    aString

    A string containing the numeric or date value.

    Return Value

    YEStrue if aString is formatted appropriately for the receiver, otherwise NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Deprecated in OS X v 10.0 and later.

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

    Deprecation Statement

    Use a formatter instead. See formatter.

    Declaration

    Objective-C

    - (void)setFloatingPointFormat:(BOOL)autoRange left:(NSUInteger)leftDigits right:(NSUInteger)rightDigits

    Parameters

    autoRange

    If YEStrue, auto-ranging is enabled, otherwise it is disabled.

    leftDigits

    The number of digits to display to the left of the decimal point.

    rightDigits

    The number of digits to display to the right of the decimal point.

    Discussion

    Sets whether floating-point numbers are auto-ranged in the receiver and sets the sizes of the fields to the left and right of the decimal point. If autoRange is NOfalse, leftDigits specifies the maximum number of digits to the left of the decimal point, and rightDigits specifies the number of digits to the right (the fractional digit places will be padded with zeros to fill this width). However, if a number is too large to fit its integer part in leftDigits digits, as many places as are needed on the left are effectively removed from rightDigits when the number is displayed.

    If autoRange is YEStrue, leftDigits and rightDigits are simply added to form a maximum total field width for the receiver (plus 1 for the decimal point). The fractional part will be padded with zeros on the right to fill this width, or truncated as much as possible (up to removing the decimal point and displaying the number as an integer). The integer portion of a number is never truncated—that is, it is displayed in full no matter what the field width limit is.

    The following example sets a cell used to display dollar amounts up to 99,999.99:

    • [[currencyDollarsField cell] setEntryType:NSFloatType];
    • [[currencyDollarsField cell] setFloatingPointFormat:NO left:5 right:2];

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.0.

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

    Deprecation Statement

    Mnemonics are not used.

    Declaration

    Objective-C

    - (void)setTitleWithMnemonic:(NSString *)aString

    Parameters

    aString

    The new title of the cell. One character in the string should be preceded by an ampersand (&) character. The character that follows becomes the mnemonic character for the title.

    Discussion

    Mnemonics are not supported in OS X.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

  • mnemonic - mnemonic (OS X v10.8)

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

    Deprecation Statement

    Mnemonics are not used.

    Declaration

    Objective-C

    - (NSString *)mnemonic

    Return Value

    A string containing the mnemonic character, or an empty string if no mnemonic character is set.

    Discussion

    Mnemonics are not supported in OS X

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

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

    Deprecation Statement

    Mnemonics are not used.

    Declaration

    Objective-C

    - (void)setMnemonicLocation:(NSUInteger)location

    Parameters

    location

    The zero-based index into the cell's title string specifying the location of the mnemonic character. The specified character is underlined when the title is drawn.

    Discussion

    Mnemonics are not supported in OS X.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

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

    Deprecation Statement

    Mnemonics are not used.

    Declaration

    Objective-C

    - (NSUInteger)mnemonicLocation

    Return Value

    A zero-based index into the receiver's title string indicating the position of the character. If there is no mnemonic character, this method returns NSNotFound.

    Discussion

    Mnemonics are not supported in OS X.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.8.

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

    Declaration

    Swift

    enum NSCellType : UInt { case NullCellType case TextCellType case ImageCellType }

    Objective-C

    typedef enum NSCellType : NSUInteger { NSNullCellType = 0, NSTextCellType = 1, NSImageCellType = 2 } NSCellType;

    Constants

    • NullCellType

      NSNullCellType

      Cell displays nothing.

      Available in OS X v10.0 and later.

    • TextCellType

      NSTextCellType

      Cell displays text.

      Available in OS X v10.0 and later.

    • ImageCellType

      NSImageCellType

      Cell displays images.

      Available in OS X v10.0 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    enum NSCellAttribute : UInt { case CellDisabled case CellState case PushInCell case CellEditable case ChangeGrayCell case CellHighlighted case CellLightsByContents case CellLightsByGray case ChangeBackgroundCell case CellLightsByBackground case CellIsBordered case CellHasOverlappingImage case CellHasImageHorizontal case CellHasImageOnLeftOrBottom case CellChangesContents case CellIsInsetButton case CellAllowsMixedState }

    Objective-C

    typedef enum NSCellAttribute : NSUInteger { NSCellDisabled = 0, NSCellState = 1, NSPushInCell = 2, NSCellEditable = 3, NSChangeGrayCell = 4, NSCellHighlighted = 5, NSCellLightsByContents = 6, NSCellLightsByGray = 7, NSChangeBackgroundCell = 8, NSCellLightsByBackground = 9, NSCellIsBordered = 10, NSCellHasOverlappingImage = 11, NSCellHasImageHorizontal = 12, NSCellHasImageOnLeftOrBottom = 13, NSCellChangesContents = 14, NSCellIsInsetButton = 15, NSCellAllowsMixedState = 16 } NSCellAttribute;

    Constants

    • CellAllowsMixedState

      NSCellAllowsMixedState

      Lets the cell’s state be NSMixedState, as well as NSOffState and NSOnState.

      Available in OS X v10.0 and later.

    • ChangeBackgroundCell

      NSChangeBackgroundCell

      If the cell’s state is NSMixedState or NSOnState, changes the cell’s background color from gray to white.

      Available in OS X v10.0 and later.

    • CellChangesContents

      NSCellChangesContents

      If the cell’s state is NSMixedState or NSOnState, displays the cell’s alternate image.

      Available in OS X v10.0 and later.

    • ChangeGrayCell

      NSChangeGrayCell

      If the cell’s state is NSMixedState or NSOnState, displays the cell’s image as darkened.

      Available in OS X v10.0 and later.

    • CellDisabled

      NSCellDisabled

      Does not let the user manipulate the cell.

      Available in OS X v10.0 and later.

    • CellEditable

      NSCellEditable

      Lets the user edit the cell’s contents.

      Available in OS X v10.0 and later.

    • CellHasImageHorizontal

      NSCellHasImageHorizontal

      Controls the position of the cell’s image: places the image on the right of any text in the cell.

      Together, NSCellHasImageOnLeftOrBottom, NSCellHasImageHorizontal, and NSCellHasOverlappingImage control the position of the cell’s image and text. To place the image above, set none of them. To place the image below, set NSCellHasImageOnLeftOrBottom. To place the image to the right, set NSCellHasImageHorizontal. To place the image to the left, set NSCellHasImageHorizontal and NSCellHasImageOnLeftOrBottom. To place the image directly over, set NSCellHasOverlappingImage.

      Available in OS X v10.0 and later.

    • CellHasImageOnLeftOrBottom

      NSCellHasImageOnLeftOrBottom

      Controls the position of the cell’s image: places the image on the left of or below any text in the cell.

      See NSCellHasImageHorizontal for more details.

      Available in OS X v10.0 and later.

    • CellHasOverlappingImage

      NSCellHasOverlappingImage

      Controls the position of the cell’s image: places the image over any text in the cell.

      See NSCellHasImageHorizontal for more details.

      Available in OS X v10.0 and later.

    • CellHighlighted

      NSCellHighlighted

      Draws the cell with a highlighted appearance.

      Use highlighted instead.

      Available in OS X v10.0 and later.

    • CellIsBordered

      NSCellIsBordered

      Draws a border around the cell.

      Available in OS X v10.0 and later.

    • CellIsInsetButton

      NSCellIsInsetButton

      Insets the cell’s contents from the border.

      By default, the cell’s contents are inset by 2 points. This constant is ignored if the cell has no border.

      Available in OS X v10.0 and later.

    • CellLightsByBackground

      NSCellLightsByBackground

      If the cell is pushed in, changes the cell’s background color from gray to white.

      Available in OS X v10.0 and later.

    • CellLightsByContents

      NSCellLightsByContents

      If the cell is pushed in, displays the cell’s alternate image.

      Available in OS X v10.0 and later.

    • CellLightsByGray

      NSCellLightsByGray

      If the cell is pushed in, displays the cell’s image as darkened.

      Available in OS X v10.0 and later.

    • PushInCell

      NSPushInCell

      Determines whether the cell’s image and text appear to be shifted down and to the right.

      Available in OS X v10.0 and later.

    • CellState

      NSCellState

      The cell’s state.

      The cell’s state can be NSMixedState, NSOffState, or NSOnState.

      Available in OS X v10.0 and later.

    Discussion

    These constants are used by the NSButton and NSButtonCell classes.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    enum NSCellImagePosition : UInt { case NoImage case ImageOnly case ImageLeft case ImageRight case ImageBelow case ImageAbove case ImageOverlaps }

    Objective-C

    typedef enum NSCellImagePosition : NSUInteger { NSNoImage = 0, NSImageOnly = 1, NSImageLeft = 2, NSImageRight = 3, NSImageBelow = 4, NSImageAbove = 5, NSImageOverlaps = 6 } NSCellImagePosition;

    Constants

    • NoImage

      NSNoImage

      The cell doesn’t display an image.

      Available in OS X v10.0 and later.

    • ImageOnly

      NSImageOnly

      The cell displays an image, but not a title.

      Available in OS X v10.0 and later.

    • ImageLeft

      NSImageLeft

      The image is to the left of the title.

      Available in OS X v10.0 and later.

    • ImageRight

      NSImageRight

      The image is to the right of the title.

      Available in OS X v10.0 and later.

    • ImageBelow

      NSImageBelow

      The image is below the title.

      Available in OS X v10.0 and later.

    • ImageAbove

      NSImageAbove

      The image is above the title.

      Available in OS X v10.0 and later.

    • ImageOverlaps

      NSImageOverlaps

      The image overlaps the title.

      Available in OS X v10.0 and later.

    Discussion

    These constants are used by the imagePosition property of NSButton and NSButtonCell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Constants for specifying a cell’s image scaling behavior.

    Declaration

    Swift

    enum NSImageScaling : UInt { case ImageScaleProportionallyDown case ImageScaleAxesIndependently case ImageScaleNone case ImageScaleProportionallyUpOrDown }

    Objective-C

    typedef enum NSImageScaling : NSUInteger { NSImageScaleProportionallyDown = 0, NSImageScaleAxesIndependently, NSImageScaleNone, NSImageScaleProportionallyUpOrDown } NSImageScaling;

    Constants

    • ScaleProportionallyDown

      NSImageScaleProportionallyDown

      If it is too large for the destination, scale the image down while preserving the aspect ratio.

      Available in OS X v10.5 and later.

    • ScaleAxesIndependently

      NSImageScaleAxesIndependently

      Scale each dimension to exactly fit destination.

      This setting does not preserve the aspect ratio of the image.

      Available in OS X v10.5 and later.

    • ScaleNone

      NSImageScaleNone

      Do not scale the image.

      Available in OS X v10.5 and later.

    • ScaleProportionallyUpOrDown

      NSImageScaleProportionallyUpOrDown

      Scale the image to its maximum possible dimensions while both staying within the destination area and preserving its aspect ratio.

      Available in OS X v10.5 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    typealias NSCellStateValue = Int

    Objective-C

    typedef enum NSCellStateValue : NSUInteger { NSMixedState = -1, NSOffState = 0, NSOnState = 1 } NSCellStateValue;

    Constants

    • NSMixedState

      NSMixedState

      The corresponding feature is in effect somewhere.

      Available in OS X v10.0 and later.

    • NSOffState

      NSOffState

      The corresponding feature is in effect nowhere.

      Available in OS X v10.0 and later.

    • NSOnState

      NSOnState

      The corresponding feature is in effect everywhere.

      Available in OS X v10.0 and later.

    Discussion

    These constants are described in Cell States.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    struct NSCellStyleMask : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var NoCellMask: NSCellStyleMask { get } static var ContentsCellMask: NSCellStyleMask { get } static var PushInCellMask: NSCellStyleMask { get } static var ChangeGrayCellMask: NSCellStyleMask { get } static var ChangeBackgroundCellMask: NSCellStyleMask { get } }

    Objective-C

    typedef enum NSCellStyleMask : NSUInteger { NSNoCellMask = 0, NSContentsCellMask = 1, NSPushInCellMask = 2, NSChangeGrayCellMask = 4, NSChangeBackgroundCellMask = 8 } NSCellStyleMask;

    Constants

    • NoCellMask

      NSNoCellMask

      The button cell doesn’t change.

      Available in OS X v10.0 and later.

    • PushInCellMask

      NSPushInCellMask

      The button cell “pushes in” if it has a border.

      Available in OS X v10.0 and later.

    • ContentsCellMask

      NSContentsCellMask

      The button cell displays its alternate icon and/or title.

      Available in OS X v10.0 and later.

    • ChangeGrayCellMask

      NSChangeGrayCellMask

      The button cell swaps the “control color” (the controlColor method of NSColor) and white pixels on its background and icon.

      Available in OS X v10.0 and later.

    • ChangeBackgroundCellMask

      NSChangeBackgroundCellMask

      Same as NSChangeGrayCellMask, but only background pixels are changed.

      Available in OS X v10.0 and later.

    Discussion

    These contents are used by the highlightsBy and showsStateBy methods of NSButtonCell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • Constants for specifying a cell’s tint.

    Declaration

    Swift

    enum NSControlTint : UInt { case DefaultControlTint case BlueControlTint case GraphiteControlTint case ClearControlTint }

    Objective-C

    typedef enum NSControlTint : NSUInteger { NSDefaultControlTint = 0, NSBlueControlTint = 1, NSGraphiteControlTint = 6, NSClearControlTint = 7 } NSControlTint;

    Constants

    • DefaultControlTint

      NSDefaultControlTint

      The current default tint setting

      Available in OS X v10.0 and later.

    • ClearControlTint

      NSClearControlTint

      Clear control tint

      Available in OS X v10.0 and later.

    • BlueControlTint

      NSBlueControlTint

      Aqua control tint

      Available in OS X v10.3 and later.

    • GraphiteControlTint

      NSGraphiteControlTint

      Graphite control tint

      Available in OS X v10.3 and later.

    Discussion

    These constants are used by controlTint property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Constants for specifying a cell’s size.

    Declaration

    Swift

    enum NSControlSize : UInt { case RegularControlSize case SmallControlSize case MiniControlSize }

    Objective-C

    typedef enum NSControlSize : NSUInteger { NSRegularControlSize, NSSmallControlSize, NSMiniControlSize } NSControlSize;

    Constants

    • RegularControlSize

      NSRegularControlSize

      The control is sized as regular.

      Available in OS X v10.0 and later.

    • SmallControlSize

      NSSmallControlSize

      The control has a smaller size.

      This constant is for controls that cannot be resized in one direction, such as push buttons, radio buttons, checkboxes, sliders, scroll bars, pop-up buttons, tabs, and progress indicators. You should use a small system font with a small control.

      Available in OS X v10.0 and later.

    • MiniControlSize

      NSMiniControlSize

      The control has a smaller size than NSSmallControlSize.

      Available in OS X v10.3 and later.

    Discussion

    These constants are used by the controlSize property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    struct NSCellHitResult : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var None: NSCellHitResult { get } static var ContentArea: NSCellHitResult { get } static var EditableTextArea: NSCellHitResult { get } static var TrackableArea: NSCellHitResult { get } }

    Objective-C

    typedef enum NSCellHitResult : NSUInteger { NSCellHitNone = 0, NSCellHitContentArea = 1 << 0, NSCellHitEditableTextArea = 1 << 1, NSCellHitTrackableArea = 1 << 2, } NSCellHitResult;

    Constants

    • None

      NSCellHitNone

      An empty area, or did not hit in the cell.

      Available in OS X v10.5 and later.

    • ContentArea

      NSCellHitContentArea

      A content area in the cell.

      Available in OS X v10.5 and later.

    • EditableTextArea

      NSCellHitEditableTextArea

      An editable text area of the cell.

      Available in OS X v10.5 and later.

    • TrackableArea

      NSCellHitTrackableArea

      A trackable area in the cell.

      Available in OS X v10.5 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • Background styles used with the backgroundStyle and interiorBackgroundStyle properties.

    Declaration

    Swift

    enum NSBackgroundStyle : Int { case Light case Dark case Raised case Lowered }

    Objective-C

    typedef enum NSBackgroundStyle : NSUInteger { NSBackgroundStyleLight = 0, NSBackgroundStyleDark, NSBackgroundStyleRaised, NSBackgroundStyleLowered } NSBackgroundStyle;

    Constants

    • Light

      NSBackgroundStyleLight

      The background is a light color.

      Dark content contrasts well with this background.

      Available in OS X v10.5 and later.

    • Dark

      NSBackgroundStyleDark

      The background is a dark color.

      Light content contrasts well with this background.

      Available in OS X v10.5 and later.

    • Raised

      NSBackgroundStyleRaised

      The background is intended to appear higher than the content drawn on it.

      Content might need to be inset.

      Available in OS X v10.5 and later.

    • Lowered

      NSBackgroundStyleLowered

      The background is intended to appear lower than the content drawn on it.

      Content might need to be embossed.

      Available in OS X v10.5 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • These are deprecated scaling constants.

    Use NSImageScaling constants instead.

    Declaration

    Objective-C

    enum { NSScaleProportionally = 0, NSScaleToFit, NSScaleNone };

    Constants

  • These constants specify how a cell formats numeric data.

    Declaration

    Swift

    var NSIntType: Int { get } var NSPositiveIntType: Int { get } var NSFloatType: Int { get } var NSPositiveFloatType: Int { get } var NSDoubleType: Int { get } var NSPositiveDoubleType: Int { get } var NSAnyType: Int { get }

    Objective-C

    enum { NSAnyType = 0, NSIntType = 1, NSPositiveIntType = 2, NSFloatType = 3, NSPositiveFloatType = 4, NSDoubleType = 6, NSPositiveDoubleType = 7 };

    Constants

    • NSIntType

      NSIntType

      Must be between INT_MIN and INT_MAX.

      Deprecated in OS X v10.4 and later.

    • NSPositiveIntType

      NSPositiveIntType

      Must be between 1 and INT_MAX.

      Deprecated in OS X v10.4 and later.

    • NSFloatType

      NSFloatType

      Must be between –FLT_MAX and FLT_MAX.

      Deprecated in OS X v10.4 and later.

    • NSPositiveFloatType

      NSPositiveFloatType

      Must be between FLT_MIN and FLT_MAX.

      Deprecated in OS X v10.4 and later.

    • NSDoubleType

      NSDoubleType

      Must be between –FLT_MAX and FLT_MAX.

      Deprecated in OS X v10.4 and later.

    • NSPositiveDoubleType

      NSPositiveDoubleType

      Must be between FLT_MIN and FLT_MAX.

      Deprecated in OS X v10.4 and later.

    • NSAnyType

      NSAnyType

      Any value is allowed.

      Deprecated in OS X v10.4 and later.

    Discussion

    These constants are used by setEntryType: and entryType.