Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AppKit.framework |
Availability | Available in Mac OS X v10.0 and later. |
Companion guide | |
Declared in | NSCell.h |
Related sample code |
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.
– setObjectValue:
– objectValue
– hasValidObjectValue
– setIntValue:
– intValue
– setIntegerValue:
– integerValue
– setStringValue:
– stringValue
– setDoubleValue:
– doubleValue
– setFloatValue:
– floatValue
– setCellAttribute:to:
– cellAttribute:
– setType:
– type
– setEnabled:
– isEnabled
– allowsUndo
– setAllowsUndo:
– setBezeled:
– isBezeled
– setBordered:
– isBordered
– isOpaque
– setControlTint:
– controlTint
– setBackgroundStyle:
– backgroundStyle
– interiorBackgroundStyle
– setEditable:
– isEditable
– setSelectable:
– isSelectable
– setScrollable:
– isScrollable
– setAlignment:
– alignment
– setFont:
– font
– lineBreakMode
– setLineBreakMode:
– truncatesLastVisibleLine
– setTruncatesLastVisibleLine:
– setWraps:
– wraps
– baseWritingDirection
– setBaseWritingDirection:
– setAttributedStringValue:
– attributedStringValue
– setAllowsEditingTextAttributes:
– allowsEditingTextAttributes
– setImportsGraphics:
– importsGraphics
– setUpFieldEditorAttributes:
– title
– setTitle:
– setFormatter:
– formatter
– isEntryAcceptable:
– setFloatingPointFormat:left:right:
– entryType
Deprecated in Mac OS X v10.0 and later
– setEntryType:
Deprecated in Mac OS X v10.0 and later
– acceptsFirstResponder
– setShowsFirstResponder:
– showsFirstResponder
– setTitleWithMnemonic:
– mnemonic
– refusesFirstResponder
– setMnemonicLocation:
– setRefusesFirstResponder:
– mnemonicLocation
– performClick:
– takeObjectValueFrom:
– takeIntegerValueFrom:
– takeIntValueFrom:
– takeStringValueFrom:
– takeDoubleValueFrom:
– takeFloatValueFrom:
– trackMouse:inRect:ofView:untilMouseUp:
– startTrackingAt:inView:
– continueTracking:at:inView:
– stopTracking:at:inView:mouseIsUp:
– mouseDownFlags
+ prefersTrackingUntilMouseUp
– getPeriodicDelay:interval:
– calcDrawInfo:
– cellSize
– cellSizeForBounds:
– drawingRectForBounds:
– imageRectForBounds:
– titleRectForBounds:
– controlSize
– setControlSize:
– drawWithFrame:inView:
– highlightColorWithFrame:inView:
– drawInteriorWithFrame:inView:
– controlView
– setControlView:
– highlight:withFrame:inView:
– setHighlighted:
– isHighlighted
– editWithFrame:inView:editor:delegate:event:
– selectWithFrame:inView:editor:delegate:start:length:
– sendsActionOnEndEditing
– setSendsActionOnEndEditing:
– endEditing:
– wantsNotificationForMarkedText
Returns the default type of focus ring for the receiver.
+ (NSFocusRingType)defaultFocusRingType
The default type of focus ring for the receiver (one of the values listed in NSFocusRingType
).
NSCell.h
Returns the default menu for instances of the receiver.
+ (NSMenu *)defaultMenu
The default menu. The NSCell
implementation of this method returns nil
.
NSCell.h
Returns a Boolean value that indicates whether tracking stops when the cursor leaves the cell.
+ (BOOL)prefersTrackingUntilMouseUp
YES
if tracking stops when the cursor leaves the cell, otherwise NO
.
The default implementation returns NO
. Subclasses may override this method to return a different value.
NSCell.h
Returns a Boolean value that indicates whether the receiver accepts first responder status.
- (BOOL)acceptsFirstResponder
YES
if the receiver can become the first responder, otherwise NO
.
The default value is YES
if the receiver is enabled. Subclasses may override this method to return a different value.
NSCell.h
Returns the default action-message selector associated with the cell.
- (SEL)action
The selector associated with the cell. The NSCell
implementation of this method returns NULL
by default.
NSCell.h
Returns the alignment of text in the receiver.
- (NSTextAlignment)alignment
The alignment of text in the receiver (one of the following constants: NSLeftTextAlignment
, NSRightTextAlignment
,NSCenterTextAlignment
, NSJustifiedTextAlignment
, NSNaturalTextAlignment
).
The default value is NSNaturalTextAlignment
.
NSCell.h
Returns a Boolean value that indicates whether the receiver allows user editing of textual attributes.
- (BOOL)allowsEditingTextAttributes
YES
if the receiver allows the user to edit textual attributes of the cell's text, otherwise NO
.
NSCell.h
Returns a Boolean value that indicates whether the receiver supports three states.
- (BOOL)allowsMixedState
YES
if the receiver supports all three states (on, off, and mixed), otherwise NO
(the receiver supports only the on and off states).
NSCell.h
Returns a Boolean value that indicates whether the receiver assumes responsibility for undo operations.
- (BOOL)allowsUndo
YES
if the receiver handles undo operations, otherwise NO
.
By default, the NSTextFieldCell
class uses this feature to handle undo operations for edited text. Other controls set a value that is appropriate for their implementation.
NSCell.h
Returns the value of the receiver’s cell as an attributed string using the receiver's formatter object (if one exists).
- (NSAttributedString *)attributedStringValue
The value of the cell interpreted as an attributed string.
The textual attributes are the default paragraph style, the receiver’s font and alignment, and whether the receiver is enabled and scrollable.
For Mac OS X v10.3 and later: If you use a class that responds to the selector attributedStringValue
for the object value of a cell, then the cell will use that method to fetch the string to draw rather than using stringValue
.
NSCell.h
Returns the background style for the receiver.
- (NSBackgroundStyle)backgroundStyle
The background style for the receiver.
The background describes the surface the cell is drawn onto in drawWithFrame:inView:
. A control typically sets this before it asks the cell to draw. A cell may draw differently based on background characteristics. For example, a tableview drawing a cell in a selected row might call [cell setBackgroundStyle: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.
NSCell.h
Returns the initial writing direction used to determine the actual writing direction for text.
- (NSWritingDirection)baseWritingDirection
The initial writing direction the receiver uses to determine the actual writing direction for text (one of the following values: NSWritingDirectionNatural
, NSWritingDirectionLeftToRight
, NSWritingDirectionRightToLeft
). If no writing direction is set, returns NSWritingDirectionNatural
.
The default value is NSWritingDirectionNatural
.
The Text system uses this value as a hint for calculating the actual direction for displaying Unicode characters. You should not need to call this method directly.
NSCell.h
Recalculates the cell geometry.
- (void)calcDrawInfo:(NSRect)aRect
The reference rectangle to use when calculating the cell information.
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.
NSCell.h
Returns the value for the specified cell attribute.
- (NSInteger)cellAttribute:(NSCellAttribute)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.
The value for the cell attribute specified by aParameter.
NSCell.h
Returns the minimum size needed to display the receiver.
- (NSSize)cellSize
The size of the cell, or the size (10000, 10000) if the receiver is not a text or image cell. If the cell is an image cell but no image has been set, returns NSZeroSize
.
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.
NSCell.h
Returns the minimum size needed to display the receiver, constraining it to the specified rectangle.
- (NSSize)cellSizeForBounds:(NSRect)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
.
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).
NSCell.h
Compares the string values of the receiver another cell, disregarding case.
- (NSComparisonResult)compare:(id)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 Mac OS X.
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.
NSCell.h
Returns a Boolean value that indicates whether mouse tracking should continue in the receiving cell.
- (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView
Contains either the initial location of the cursor when tracking began or the previous current point.
The current location of the cursor.
The NSControl
object managing the receiver.
YES
if mouse tracking should continue, otherwise NO
.
This method is invoked in trackMouse:inRect:ofView:untilMouseUp:
. The default implementation returns YES
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.
NSCell.h
Returns the size of the receiver.
- (NSControlSize)controlSize
A value that specifies the size of the receiver (for possible values, see “Control Sizes”
).
NSCell.h
Returns the receiver’s control tint.
- (NSControlTint)controlTint
An NSControlTint
value that specifies the tint of the receiver (see “Control Tints”
for possible values).
NSCell.h
Returns the receiver's control.
- (NSView *)controlView
The view (normally an NSControl
object) associated with this cell. The default implementation returns nil
.
NSCell.h
Returns the value of the receiver’s cell as a double-precision floating-point number.
- (double)doubleValue
The value of the cell interpreted as a double-precision floating-point number. If the receiver is not a text-type cell or the cell value is not scannable, returns 0
.
NSCell.h
Returns the rectangle within which the receiver draws itself
- (NSRect)drawingRectForBounds:(NSRect)theRect
The bounding rectangle of the receiver.
The rectangle in which the receiver draws itself. This rectangle is slightly inset from the one in theRect
.
– calcSize
(NSControl
)NSCell.h
Draws the interior portion of the receiver, which includes the image or text portion but does not include the border.
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
The bounding rectangle of the receiver, or a portion of the bounding rectangle.
The control that manages the cell.
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.
NSCell.h
Instructs the receiver to draw in an expansion frame.
- (void)drawWithExpansionFrame:(NSRect)cellFrame inView:(NSView *)view
The frame in which to draw.
The view in which to draw. This view may be different from the original view that the cell appeared in.
This method allows the cell to perform custom expansion tool tip drawing. By default, NSCell
simply calls drawWithFrame:inView:
.
NSCell.h
Draws the receiver’s border and then draws the interior of the cell.
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
The bounding rectangle of the receiver.
The control that manages the cell.
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.
NSCell.h
Begins editing of the receiver’s text using the specified field editor.
- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent
The bounding rectangle of the cell.
The control that manages the cell.
The field editor to use for editing the cell.
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.
The NSLeftMouseDown
event that initiated the editing behavior.
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.
NSCell.h
Ends the editing of text in the receiver using the specified field editor.
- (void)endEditing:(NSText *)textObj
The field editor currently handling the editing of the cell's content.
Ends any editing of text that began with a call to editWithFrame:inView:editor:delegate:event:
or selectWithFrame:inView:editor:delegate:start:length:
.
NSCell.h
Returns the expansion cell frame for the receiver.
- (NSRect)expansionFrameWithFrame:(NSRect)cellFrame inView:(NSView *)view
The frame for the receiver.
The view in which the receiver will be drawn.
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.
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.
NSCell.h
Returns the value of the receiver’s cell as a single-precision floating-point number.
- (float)floatValue
The value of the cell interpreted as a single-precision floating-point number. If the receiver is not a text-type cell or the cell value is not scannable, returns 0
.
NSCell.h
Returns the type of focus ring currently set for the receiver.
- (NSFocusRingType)focusRingType
The type of focus ring currently set for the receiver (one of the values listed in NSFocusRingType
).
You can disable a view's focus ring drawing by overriding this method so it always returns NSFocusRingTypeNone
, or by calling setFocusRingType:
with NSFocusRingTypeNone
. You should only disable a view from drawing its focus ring if you want to draw your own focus ring, or if there isn't sufficient space to display a focus ring in the default location.
NSCell.h
Returns the font used to display text in the receiver
- (NSFont *)font
The receiver's current font, or nil
if the receiver is not a text-type cell.
NSCell.h
Returns the receiver's formatter object.
- (id)formatter
An object of type NSFormatter
used to format the receiver's content.
The returned object handles translation of the receiver’s contents between its onscreen representation and its object value.
NSCell.h
Returns the initial delay and repeat values for continuous sending of action messages to target objects.
- (void)getPeriodicDelay:(float *)delay interval:(float *)interval
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
.
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
.
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.
NSCell.h
Returns a Boolean value that indicates whether the receiver has a valid object value.
- (BOOL)hasValidObjectValue
YES
if the cell has a valid object value, otherwise NO
.
A valid object value is one that the receiver'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 receiver’s NSControl
object (using the control:didFailToFormatString:errorDescription:
delegate method).
NSCell.h
Redraws the receiver with the specified highlight setting.
- (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView:(NSView *)controlView
If YES
, the cell is redrawn with a highlight; otherwise, if NO
, the highlight is removed.
The bounding rectangle of the receiver.
The control that manages the cell.
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.
NSCell.h
Returns the color the receiver uses when drawing the selection highlight.
- (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
The bounding rectangle of the receiver.
The control that manages the cell.
The color the receiver uses when drawing the selection highlight.
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.
NSCell.h
Returns hit testing information for the receiver.
- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView
The current event.
The cell’s frame.
The control object in which the cell is located.
A constant that specifies the type of area in which the event occurred—see “Hit Testing”
for values.
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
.
NSCell.h
Returns the image displayed by the receiver (if any).
- (NSImage *)image
The image displayed by the receiver, or nil
if the receiver is not an image-type cell.
NSCell.h
Returns the rectangle in which the receiver draws its image.
- (NSRect)imageRectForBounds:(NSRect)theRect
The bounding rectangle of the receiver.
The rectangle in which the receiver draws its image. This rectangle is slightly offset from the one in theRect
.
NSCell.h
Returns a Boolean value that indicates whether the text of the receiver can contain imported graphics.
- (BOOL)importsGraphics
YES
if the receiver's text is in the RTFD format and supports imported graphics, otherwise NO
.
NSCell.h
Returns an NSCell
object initialized with the specified image and set to have the cell’s default menu.
- (id)initImageCell:(NSImage *)anImage
The image to use for the cell. If this parameter is nil
, no image is set.
An initialized NSCell
object, or nil
if the cell could not be initialized.
NSCell.h
Returns an NSCell object initialized with the specified string and set to have the cell’s default menu.
- (id)initTextCell:(NSString *)aString
The initial string to use for the cell.
An initialized NSCell
object, or nil
if the cell could not be initialized.
If no field editor (a shared NSText
object) has been created for all NSCell
objects, one is created.
NSCell.h
Returns the receiver’s value as an NSInteger
.
- (NSInteger)integerValue
The value of the cell interpreted as an NSInteger
. If the receiver is not a text-type cell or the cell value is not scannable, returns 0
.
NSCell.h
Returns the interior background style for the receiver.
- (NSBackgroundStyle)interiorBackgroundStyle
Returns the interior background style for the receiver.
The interior background style describes the surface drawn onto in drawInteriorWithFrame:inView:
. This is often the same as the backgroundStyle
, but a button that draws a bezel would have a different interiorBackgroundStyle
.
This is both an override point and a useful method to call. In a custom button with a custom bezel you can override this method to describe that surface. A cell that has custom interior drawing might query this method to help pick an image that looks good on the cell. Calling this method gives you some independence from changes in framework art style.
NSCell.h
Returns the receiver’s value as an integer.
- (int)intValue
The value of the cell interpreted as an integer. If the receiver is not a text-type cell or the cell value is not scannable, returns 0
.
On Mac OS X v10.5 and later, you should use integerValue
instead.
NSCell.h
Returns a Boolean value that indicates whether the receiver has a bezeled border.
- (BOOL)isBezeled
YES
if the receiver has a bezeled border, otherwise NO
.
NSCell.h
Returns a Boolean value that indicates whether the receiver has a plain border.
- (BOOL)isBordered
YES
if the receiver has a plain border, otherwise NO
.
NSCell.h
Returns a Boolean value that indicates whether the receiver’s cell sends its action message continuously to its target during mouse tracking.
- (BOOL)isContinuous
YES
if the action message should be sent continuously, otherwise NO
.
NSCell.h
Returns a Boolean value that indicates whether the receiver is editable.
- (BOOL)isEditable
YES
if the receiver is editable, otherwise NO
.
NSCell.h
Returns a Boolean value that indicates whether the receiver is enabled or disabled.
- (BOOL)isEnabled
YES
if the receiver is enabled, otherwise NO
.
NSCell.h
Returns whether a string representing a numeric or date value is formatted in a suitable way for the cell's entry type.
- (BOOL)isEntryAcceptable:(NSString *)aString
A string containing the numeric or date value.
YES
if aString is formatted appropriately for the receiver, otherwise NO
.
This method is being deprecated in favor of a new class of formatter objects. For more information, see NSFormatter
. This documentation is provided only for developers who need to modify older applications
NSCell.h
Returns a Boolean value that indicates whether the receiver is highlighted.
- (BOOL)isHighlighted
YES
if the receiver has a highlight, otherwise NO
.
NSCell.h
Returns a Boolean value that indicates whether the receiver is opaque (nontransparent).
- (BOOL)isOpaque
YES
if the receiver is opaque, otherwise NO
to indicate the receiver might have some transparency.
NSCell.h
Returns a Boolean value that indicates whether the receiver scrolls excess text past the cell’s bounds.
- (BOOL)isScrollable
YES
if excess text scrolls past the cell's bounds, otherwise NO
(text wrapping is enabled).
NSCell.h
Returns a Boolean value that indicates whether the text of the receiver can be selected.
- (BOOL)isSelectable
YES
if the receiver's text can be selected, otherwise NO
.
NSCell.h
Returns the key equivalent to clicking the cell.
- (NSString *)keyEquivalent
An empty string object.
Subclasses can override this method to return a string with a valid character for the key equivalent.
NSCell.h
Returns the line break mode currently used when drawing text.
- (NSLineBreakMode)lineBreakMode
The line break mode the receiver currently uses when drawing text (one of the following constants: NSLineBreakByWordWrapping
, NSLineBreakByCharWrapping
, NSLineBreakByClipping
, NSLineBreakByTruncatingHead
, NSLineBreakByTruncatingTail
, or NSLineBreakByTruncatingMiddle
).
NSCell.h
Returns the receiver’s contextual menu.
- (NSMenu *)menu
The receiver’s contextual menu, or nil
if no menu is assigned.
NSCell.h
Returns the menu associated with the receiver and related to the specified event and frame.
- (NSMenu *)menuForEvent:(NSEvent *)anEvent inRect:(NSRect)cellFrame ofView:(NSView *)aView
The event used to find the menu.
The cell's rectangle. This rectangle indicates the region containing the cursor.
The view that manages the receiver. This is usually the control object that owns the cell.
The menu associated with the cell and event parameters, or nil
if no menu is set.
This method is usually invoked by the NSControl
object (aView) managing the receiver. The default implementation simply invokes menu
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.
NSCell.h
Returns the character in the receiver’s title that appears underlined for use as a mnemonic.
- (NSString *)mnemonic
A string containing the mnemonic character, or an empty string if no mnemonic character is set.
Mnemonics are not supported in Mac OS X
NSCell.h
Returns the position of the underlined mnemonic character in the receiver’s title.
- (NSUInteger)mnemonicLocation
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
.
Mnemonics are not supported in Mac OS X.
NSCell.h
Returns the modifier flags for the last (left) mouse-down event.
- (NSInteger)mouseDownFlags
The modifier flags, or 0
if tracking has not yet occurred or no modifier keys accompanied the mouse-down event.
– modifierFlags
(NSEvent
)NSCell.h
Returns the receiver’s next state.
- (NSInteger)nextState
The receiver’s next state (for possible values, see “Cell States”
).
If the receiver has three states, it cycles through them in this order: on, off, mixed, on, and so forth. If the receiver has two states, it toggles between them.
NSCell.h
Returns the receiver’s value as an Objective-C object
- (id)objectValue
The receiver's object value, or nil
if a valid object has not been associated with the receiver.
To be valid object value, the receiver must have a formatter capable of converting the object to and from its textual representation.
NSCell.h
Simulates a single mouse click on the receiver.
- (void)performClick:(id)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
.
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.
NSCell.h
Returns the prepared image for the receiver.
- (NSImage *)preparedImage
The prepared image for the receiver.
By default, this method returns a processed version of the cell's image or alternate image that takes into account interiorBackgroundStyle
and state. For example, a button cell might display a darker version of the cell's image when pressed. You can override this method to return an image based on any arbitrary parameters.
Returns a Boolean value that indicates whether the receiver should not become the first responder.
- (BOOL)refusesFirstResponder
YES
if the receiver should never become the first responder, otherwise NO
if the receiver can become the first responder.
To find out whether the receiver can become first responder at this time, use the method acceptsFirstResponder
.
NSCell.h
Returns the object the receiver represents.
- (id)representedObject
The object represented by the receiver.
Represented objects let you link a cell to an appropriate object. For example, you could have a pop-up list of color names, and the represented objects could be the appropriate NSColor
objects.
Note that if you copy an NSCell
instance, the represented object in the copy is set to nil
.
NSCell.h
Sets the receiver to show the I-beam cursor while it tracks the mouse.
- (void)resetCursorRect:(NSRect)cellFrame inView:(NSView *)controlView
The rectangle in which to display the I-beam cursor.
The control that manages the cell.
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.
NSCell.h
Selects the specified text range in the cell's field editor.
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength
The bounding rectangle of the cell.
The control that manages the cell.
The field editor to use for editing the cell.
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.
The start of the text selection.
The length of the text range.
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.
NSCell.h
Sets the conditions on which the receiver sends action messages to its target.
- (NSInteger)sendActionOn:(NSInteger)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.
A bit mask containing the previous settings. This bit mask uses the same values as specified in the mask parameter.
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 setContinuous:
method to turn on the flag corresponding to NSPeriodicMask
or NSLeftMouseDraggedMask
, whichever is appropriate to the given subclass of NSCell
.
NSCell.h
Returns a Boolean value that indicates whether the receiver’s NSControl
object sends its action message whenever the user finishes editing the cell’s text.
- (BOOL)sendsActionOnEndEditing
YES
if the receiver's control sends its action message when editing is complete, otherwise NO
.
If this method returns YES
, the receiver’s NSControl
object sends its action message 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
If it returns NO
, the cell’s NSControl
object sends its action message only when the user presses the Return key.
NSCell.h
Sets the cell's action method to the specified selector.
- (void)setAction:(SEL)aSelector
The new action-message selector to associate with the receiver's cell. Specify NULL
to prevent action messages from being sent to the receiver's target.
The NSCell
implementation of this method raises NSInternalInconsistencyException
. Subclasses (such as NSActionCell
) override this method to set the action method as part of the target/action implementation.
NSCell.h
Sets the alignment of text in the receiver.
- (void)setAlignment:(NSTextAlignment)mode
This value can be one of the following constants: NSLeftTextAlignment
, NSRightTextAlignment
,NSCenterTextAlignment
, NSJustifiedTextAlignment
, orNSNaturalTextAlignment
.
NSCell.h
Sets whether the receiver allows the user to edit textual attributes of its contents.
- (void)setAllowsEditingTextAttributes:(BOOL)flag
If YES
, the user can modify the font and other textual attributes of the cell's text. If NO
, the user cannot edit the text or import graphics, which effectively means the cell cannot support RTFD text.
NSCell.h
Sets whether the receiver supports three states or just two.
- (void)setAllowsMixedState:(BOOL)flag
If YES
, the receiver supports three states (on, off, and mixed); otherwise, if NO
, the receiver supports only two states (on and off).
NSCell.h
Sets whether the receiver assumes responsibility for undo operations within the cell.
- (void)setAllowsUndo:(BOOL)allowsUndo
If YES
, the receiver handles undo operations; otherwise, if NO
, the application's custom undo manager handles undo operations.
Subclasses invoke this method to indicate their preference for handling undo operations; otherwise, you should not need to call this method directly.
NSCell.h
Sets the value of the receiver’s cell using an attributed string.
- (void)setAttributedStringValue:(NSAttributedString *)attribStr
The value of the cell interpreted as an attributed string.
If a formatter is set for the receiver, but the formatter does not understand the attributed string, it marks attribStr as an invalid object. If the receiver is not a text-type cell, it is converted to one before the value is set.
For Mac OS X v10.3 and later: If you use a class that responds to the selector attributedStringValue
for the object value of a cell, then the cell uses that method to fetch the string to draw rather than using stringValue
.
The following example sets the text in a cell to 14 points, red, in the system font.
NSColor *txtColor = [NSColor redColor]; |
NSFont *txtFont = [NSFont boldSystemFontOfSize:14]; |
NSDictionary *txtDict = [NSDictionary dictionaryWithObjectsAndKeys: |
txtFont, NSFontAttributeName, txtColor, NSForegroundColorAttributeName, nil]; |
NSAttributedString *attrStr = [[[NSAttributedString alloc] |
initWithString:@"Hello!" attributes:txtDict] autorelease]; |
[[attrStrTextField cell] setAttributedStringValue:attrStr]; |
[attrStrTextField updateCell:[attrStrTextField cell]]; |
NSCell.h
Sets the background style for the receiver.
- (void)setBackgroundStyle:(NSBackgroundStyle)style
The background style for the receiver.
NSCell.h
Sets the initial writing direction used to determine the actual writing direction for text .
- (void)setBaseWritingDirection:(NSWritingDirection)writingDirection
One of the following values: NSWritingDirectionNatural
, NSWritingDirectionLeftToRight
, or NSWritingDirectionRightToLeft
.
If you know the base writing direction of the text you are rendering, you can use this method to specify that direction to the text system.
NSCell.h
Sets whether the receiver draws itself with a bezeled border.
- (void)setBezeled:(BOOL)flag
If YES
, the receiver uses a bezeled border.
The setBezeled:
and setBordered:
methods are mutually exclusive (that is, a border can be only plain or bezeled). Invoking this method automatically removes any border that had already been set, regardless of the value in the flag
parameter.
NSCell.h
Sets whether the receiver draws itself outlined with a plain border.
- (void)setBordered:(BOOL)flag
If YES
, the receiver uses a plain border.
The setBezeled:
and setBordered:
methods are mutually exclusive (that is, a border can be only plain or bezeled). Invoking this method automatically removes any bezel that had already been set, regardless of the value in the flag
parameter.
NSCell.h
Sets the value for the specified cell attribute.
- (void)setCellAttribute:(NSCellAttribute)aParameter to:(NSInteger)value
The cell attribute whose value you want to set. Attributes include the receiver's current state and whether it is disabled, editable, or highlighted.
The new value for the attribute.
NSCell.h
Sets whether the receiver’s cell sends its action message continuously to its target during mouse tracking.
- (void)setContinuous:(BOOL)flag
If YES
, the action message should be sent continuously.
In practice, the continuous setting 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.
NSCell.h
Sets the size of the receiver.
- (void)setControlSize:(NSControlSize)size
A value that specifies the size of the receiver (for possible values, see “Control Sizes”
).
Changing the cell’s control size does not change the font of the cell. Use the systemFontSizeForControlSize:
class method of NSFont
to obtain the system font based on the new control size and set it.
NSCell.h
Sets the receiver’s control tint.
- (void)setControlTint:(NSControlTint)controlTint
An NSControlTint
value that specifies the tint of the receiver (see “Control Tints”
for possible values).
NSCell.h
Sets the receiver’s control view.
- (void)setControlView:(NSView *)view
The view (normally an NSControl
object) to associate with the cell.
The control view represents the control currently being rendered by the cell.
NSCell.h
Sets the value of the receiver’s cell using a double-precision floating-point number.
- (void)setDoubleValue:(double)aDouble
The value of the cell interpreted as a double-precision floating-point number.
In its implementation, this method invokes the setObjectValue:
method to set the actual value. This method does nothing if the receiver is not a text-type cell.
NSCell.h
Sets whether the user can edit the receiver’s text.
- (void)setEditable:(BOOL)flag
If YES
, the user is allowed to edit the receiver's text. If this value is YES
, the text is also made selectable. If it is NO
, the selectable attribute is restored to the value it was before the cell was last made editable.
NSCell.h
Sets whether the receiver is enabled or disabled.
- (void)setEnabled:(BOOL)flag
If YES
the receiver is enabled; otherwise, if NO
, the receiver is disabled.
The text of disabled cells is changed to gray. If a cell is disabled, it cannot be highlighted, does not support mouse tracking (and thus cannot participate in target/action functionality), and cannot be edited. However, you can still alter many attributes of a disabled cell programmatically. (The setState:
method, for instance, still works.)
NSCell.h
Sets the autoranging and floating point number format of the receiver’s cell.
- (void)setFloatingPointFormat:(BOOL)autoRange left:(NSUInteger)leftDigits right:(NSUInteger)rightDigits
If YES
, autoranging is enabled, otherwise it is disabled.
The number of digits to display to the left of the decimal point.
The number of digits to display to the right of the decimal point.
Sets whether floating-point numbers are autoranged in the receiver and sets the sizes of the fields to the left and right of the decimal point. If autoRange is NO
, 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 YES
, 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]; |
Note: This method is being deprecated in favor of a new class of formatter objects. For more information, see NSFormatter
. This documentation is provided only for developers who need to modify older applications.
NSCell.h
Sets the value of the receiver’s cell using a single-precision floating-point number.
- (void)setFloatValue:(float)aFloat
The value of the cell interpreted as a single-precision floating-point number.
In its implementation, this method invokes the setObjectValue:
method to set the actual value. This method does nothing if the receiver is not a text-type cell.
NSCell.h
Sets the type of focus ring to be used.
- (void)setFocusRingType:(NSFocusRingType)focusRingType
Possible values are listed in NSFocusRingType
. To disable a view's focus ring, specify NSFocusRingTypeNone
.
You should only disable a view from drawing its focus ring if you want to draw your own focus ring, or if there is not sufficient space to display a focus ring in the default location.
NSCell.h
Sets the font to use when the receiver displays text.
- (void)setFont:(NSFont *)fontObj
The font to use.
If the receiver is not a text-type cell, the method converts it to that type before setting the font.
NSCell.h
Sets the receiver's formatter object.
- (void)setFormatter:(NSFormatter *)newFormatter
The formatter to use with the cell, or nil
if you do not want the cell to use a formatter.
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. If the new formatter cannot interpret the receiver’s current object value, that value is converted to a string object.
NSCell.h
Sets whether the receiver has a highlighted appearance.
- (void)setHighlighted:(BOOL)flag
If YES, the receiver has a highlight.
By default, this method does nothing. The NSButtonCell
class overrides this method to draw the button with the appearance specified by NSCellLightsByBackground
, NSCellLightsByContents
, or NSCellLightsByGray
.
NSCell.h
Sets the image to be displayed by the receiver.
- (void)setImage:(NSImage *)image
The image to display in the cell.
If the receiver is not an image-type cell, the method converts it to that type of cell.
NSCell.h
Sets whether the receiver can import images into its text.
- (void)setImportsGraphics:(BOOL)flag
If YES
, the receiver can import images into its text and support RTFD text. If NO
, RTFD text is not supported.
If flag is YES
, the receiver is also set to allow editing of text attributes.
NSCell.h
Sets the value of the receiver using an NSInteger
.
- (void)setIntegerValue:(NSInteger)anInteger
The value of the cell interpreted as an NSInteger
.
In its implementation, this method invokes the setObjectValue:
method to set the actual value. This method does nothing if the receiver is not a text-type cell.
NSCell.h
Sets the value of the receiver using an integer.
- (void)setIntValue:(int)anInt
The value of the cell interpreted as an integer.
In its implementation, this method invokes the setObjectValue:
method to set the actual value. This method does nothing if the receiver is not a text-type cell.
On Mac OS X v10.5 and later, you should use setIntegerValue:
instead.
NSCell.h
Sets the line break mode to use when drawing text
- (void)setLineBreakMode:(NSLineBreakMode)mode
The desired line break mode, which should be one of the following constants: NSLineBreakByWordWrapping
, NSLineBreakByCharWrapping
, NSLineBreakByClipping
, NSLineBreakByTruncatingHead
, NSLineBreakByTruncatingTail
, or NSLineBreakByTruncatingMiddle
.
The line break mode can also be modified by calling the setWraps:
method.
NSCell.h
Sets the contextual menu for the cell.
- (void)setMenu:(NSMenu *)aMenu
A menu that has commands contextually related to the receiver. Specify nil
to clear the previous menu.
NSCell.h
Sets the character of the receiver’s title to be used as a mnemonic character.
- (void)setMnemonicLocation:(NSUInteger)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.
Mnemonics are not supported in Mac OS X.
NSCell.h
Changes the state of the receiver to its next state.
- (void)setNextState
If the receiver has three states, it cycles through them in this order: on, off, mixed, on, and so forth. If the receiver has two states, it toggles between them.
NSCell.h
Sets the receiver’s object value.
- (void)setObjectValue:(id < NSCopying >)object
The new object value for the cell.
To be valid object value, the receiver must have a formatter capable of converting the object to and from its textual representation.
NSCell.h
Sets whether the receiver should not become the first responder.
- (void)setRefusesFirstResponder:(BOOL)flag
If YES
, the receiver should never become the first responder; otherwise, it may become the first responder.
If refusesFirstResponder
returns NO
and the cell is enabled, the method acceptsFirstResponder
returns YES
, allowing the cell to become first responder.
NSCell.h
Sets the object represented by the receiver.
- (void)setRepresentedObject:(id)anObject
The object to associate with the receiver.
You can use this method to link two objects together. For example, if the receiver's title was "Blue", you could associate an NSColor
object whose color was set to blue.
Note that if you copy an NSCell
instance, the represented object in the copy is set to nil
.
NSCell.h
Sets whether excess text in the receiver is scrolled past the cell’s bounds.
- (void)setScrollable:(BOOL)flag
If YES
, text can be scrolled past the cell's bounds; otherwise, if NO
, the text wrapping is enabled.
NSCell.h
Sets whether text in the receiver can be selected.
- (void)setSelectable:(BOOL)flag
If YES
, the receiver's text can be selected. If this value is NO
, editability is also disabled; if it is YES
, editability is not affected.
NSCell.h
Sets whether the receiver’s NSControl object sends its action message whenever the user finishes editing the cell’s text.
- (void)setSendsActionOnEndEditing:(BOOL)flag
If YES
, the receiver's control sends its action message when editing is complete; otherwise, if NO
, it sends the action message only when the user presses the Return key.
If flag is YES
, the receiver’s NSControl
object sends its action message 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
NSCell.h
Sets whether the receiver draws some indication of its first responder status.
- (void)setShowsFirstResponder:(BOOL)flag
If YES
, the receiver draws an indication of its first responder status, otherwise it does not.
NSCell.h
Sets the receiver’s state to the specified value.
- (void)setState:(NSInteger)value
The possible state values are NSOnState
, NSOffState
, and NSMixedState
. If the cell supports only two states and you specify NSMixedState
, this method sets the state to NSOnState
.
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, value can also be an integer. 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, as NSMixedState
; and a positive value, as NSOnState
.
Note that the value state
returns may not be the same value you passed into the value
parameter.
To check whether the cell has three states (and uses the mixed state), invoke the allowsMixedState
method.
NSCell.h
Sets the value of the receiver’s cell using an NSString
object.
- (void)setStringValue:(NSString *)aString
The string value of the cell.
In its implementation, this method invokes the setObjectValue:
method to set the actual value. If no formatter is assigned to the receiver or if the formatter cannot “translate” aString to an underlying object, the receiver is flagged as having an invalid object. If the receiver is not a text-type cell, this method converts it to one before setting the object value.
For Mac OS X v10.3 and later: If you use a class that responds to the selector attributedStringValue
for the object value of a cell, the cell uses that method to fetch the string to draw rather than the stringValue
method.
NSCell.h
Sets the tag of the receiver.
- (void)setTag:(NSInteger)anInteger
The new tag for the cell.
The NSCell
implementation of this method raises NSInternalInconsistencyException
. The NSActionCell
implementation sets the receiver’s tag integer to anInteger.
Tags allow you to identify particular cells. Tag values are not used internally; they are only changed by external invocations of setTag:
. 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.
NSCell.h
Sets the target object to receive action messages.
- (void)setTarget:(id)anObject
The new target object to associate with the receiver's cell, or nil
to remove the current target.
The NSCell
implementation of this method raises NSInternalInconsistencyException
. Subclasses (such as NSActionCell
) override this method to set the target object as part of the target/action implementation.
NSCell.h
Sets the title of the receiver.
- (void)setTitle:(NSString *)aString
The new string value for the cell.
NSCell.h
Sets the title of the receiver with one character in the string denoted as an access key.
- (void)setTitleWithMnemonic:(NSString *)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.
Mnemonics are not supported in Mac OS X.
NSCell.h
Sets whether the receiver truncates and adds the ellipsis character to the last visible line if the text doesn't fit into the cell bounds.
- (void)setTruncatesLastVisibleLine:(BOOL)flag
If YES
, the receiver truncates the last line; if NO
, it does not truncate.
The line break mode must be either NSLineBreakByWordWrapping
or NSLineBreakByCharWrapping
. Otherwise, this setting is ignored.
NSCell.h
Sets the type of the cell, changing it to a text cell, image cell, or null cell.
- (void)setType:(NSCellType)aType
The new type of the cell (see “Cell Types”
for possible values).
If the cell is already the same type as the one specified in the aType parameter, this method does nothing.
If aType is NSTextCellType
, this method converts the receiver to a cell of that type, giving it a default title and setting the font to the system font at the default size. If aType is NSImageCellType
, the cell type is not changed until you set a new non-nil
image.
NSCell.h
Configures the textual and background attributes of the receiver's field editor.
- (NSText *)setUpFieldEditorAttributes:(NSText *)textObj
The field editor to configure. .
The configured field editor.
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
.
NSCell.h
Sets whether text in the receiver wraps when its length exceeds the frame of the cell.
- (void)setWraps:(BOOL)flag
If YES
, the receiver wraps text and also makes the receiver nonscrollable; otherwise, if NO
, text is not wrapped.
If the text of the receiver is an attributed string value you must explicitly set the paragraph style line break mode. Calling this method with the value YES
is equivalent to calling the setLineBreakMode:
method with the value NSLineBreakByWordWrapping
.
NSCell.h
Returns a Boolean value that indicates whether the receiver should draw some indication of its first responder status.
- (BOOL)showsFirstResponder
YES
if the receiver should draw an indication of its first responder status, otherwise NO
.
The NSCell
class itself does not draw a first-responder indicator. Subclasses may use the returned value to determine whether or not they should draw one, however.
NSCell.h
Begins tracking mouse events within the receiver.
- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView
The initial location of the cursor.
The NSControl
object managing the receiver.
YES
if the receiver is set to respond continuously or set to respond when the mouse is dragged, otherwise NO
.
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.
NSCell.h
Returns the receiver’s state.
- (NSInteger)state
The receiver’s state (for possible values, see “Cell States”
).
Cells can have two or three states. If the receiver has two states, it returns either NSOffState
(the normal or unpressed state) or NSOnState
(the alternate or pressed state). If it has three, it may also return NSMixedState
, indicating the feature is in effect somewhere.
To check whether the receiver uses the mixed state, use the method allowsMixedState
.
Note that the value state
returns may not be the same value you passed into setState:
.
NSCell.h
Stops tracking mouse events within the receiver.
- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag
Contains the previous position of the cursor.
The current location of the cursor.
The NSControl
object managing the receiver.
If YES
, this method was invoked because the user released the mouse button; otherwise, if NO
, the cursor left the designated tracking rectangle.
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)]; |
} |
} |
NSCell.h
Returns the value of the receiver’s cell as an NSString
object.
- (NSString *)stringValue
The string value of the cell. This value may be an interpreted version of the cell's actual value. Interpretations are performed by the cell's formatter.
If no formatter exists and the cell's value is an NSString
object, this method returns the value as a plain, attributed, or localized formatted string. If the value is not an NSString
object or cannot be converted to one, this method returns an empty string.
For Mac OS X v10.3 and later: If you use a class that responds to the selector attributedStringValue
for the object value of a cell, the cell uses that method to fetch the string to draw rather than the stringValue
method.
NSCell.h
Returns the tag identifying the receiver.
- (NSInteger)tag
The tag value. The NSCell
implementation of this method returns –1
.
Tags allow you to identify particular cells. Tag values are not used internally; they are only changed by external invocations of setTag:
. 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.
NSCell.h
Sets the value of the receiver’s cell to a double-precision floating-point value obtained from the specified object.
- (void)takeDoubleValueFrom:(id)sender
The object from which to take the value. This object must respond to the doubleValue
message.
NSCell.h
Sets the value of the receiver’s cell to a single-precision floating-point value obtained from the specified object.
- (void)takeFloatValueFrom:(id)sender
The object from which to take the value. This object must respond to the floatValue
message.
NSCell.h
Sets the value of the receiver’s cell to an integer value obtained from the specified object.
- (void)takeIntegerValueFrom:(id)sender
The object from which to take the value. This object must respond to the integerValue
message.
NSCell.h
Sets the value of the receiver’s cell to an integer value obtained from the specified object.
- (void)takeIntValueFrom:(id)sender
The object from which to take the value. This object must respond to the intValue
message.
On Mac OS X v10.5 and later you should use takeIntegerValueFrom:
instead.
NSCell.h
Sets the value of the receiver’s cell to the object value obtained from the specified object.
- (void)takeObjectValueFrom:(id)sender
The object from which to take the value. This object must respond to the objectValue
message.
NSCell.h
Sets the value of the receiver’s cell to the string value obtained from the specified object.
- (void)takeStringValueFrom:(id)sender
The object from which to take the value. This object must respond to the stringValue
message.
NSCell.h
Returns the target object of the receiver.
- (id)target
The target object that receives action messages from the cell. The NSCell
implementation of this method returns nil
.
Subclasses (such as NSActionCell
) override this method to return the target object as part of the target/action implementation.
NSCell.h
Returns the receiver’s title.
- (NSString *)title
The cell's string value.
Subclasses (such as NSButtonCell
) may override this method to return a different value.
NSCell.h
Returns the rectangle in which the receiver draws its title text.
- (NSRect)titleRectForBounds:(NSRect)theRect
The bounding rectangle of the receiver.
The rectangle in which the receiver draws its title text.
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.
NSCell.h
Initiates the mouse tracking behavior in a cell.
- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp
The event that caused the mouse tracking to occur.
The receiver's frame rectangle.
The view containing the receiver. This is usually an NSControl
object.
If YES
, mouse tracking continues until the user releases the mouse button; otherwise, if NO
, 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.
YES
if the mouse tracking conditions are met, otherwise NO
.
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 YES
, this method returns YES
if the mouse button goes up while the cursor is anywhere; NO
, otherwise. If untilMouseUp is set to NO
, this method returns YES
if the mouse button goes up while the cursor is within cellFrame; NO
, otherwise.
This method first invokes startTrackingAt:inView:
. If that method returns YES
, then as mouse-dragged events are intercepted, continueTracking:at:inView:
is invoked until either the method returns NO
or the mouse is released. Finally, stopTracking:at:inView:mouseIsUp:
is invoked if the mouse is released. If untilMouseUp is YES
, it’s invoked when the mouse button goes up while the cursor is anywhere. If untilMouseUp is NO
, 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.
NSCell.h
Returns a Boolean value indicating whether the receiver truncates and adds the ellipsis character to the last visible line if the text doesn't fit into the cell bounds.
- (BOOL)truncatesLastVisibleLine
YES
if the receiver truncates the last line; otherwise NO
.
The line break mode must be either NSLineBreakByWordWrapping
or NSLineBreakByCharWrapping
. Otherwise, this setting is ignored.
NSCell.h
Returns the type of the receiver
- (NSCellType)type
The type of the cell (see “Cell Types”
for possible values).
NSCell.h
Returns a Boolean value that indicates whether the field editor initiated by the receiver should post text change notifications.
- (BOOL)wantsNotificationForMarkedText
YES
if the field editor initiated by the receiver should post text change notifications (NSTextDidChangeNotification
) while editing marked text; otherwise, they are delayed until the marked text confirmation.
NSCell
's implementation returns NO
.
NSCell.h
Returns a Boolean value that indicates whether the receiver wraps its text when the text exceeds the borders of the cell.
- (BOOL)wraps
YES
if the receiver wraps text, otherwise NO
.
NSCell.h
Defines a type for cell types.
typedef NSUInteger NSCellType;
For possible values, see “Cell Types.”
NSCell.h
These constants specify how a cell represents its data (as text or as an image).
enum { NSNullCellType = 0, NSTextCellType = 1, NSImageCellType = 2 };
NSNullCellType
Cell displays nothing.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSTextCellType
Cell displays text.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSImageCellType
Cell displays images.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
These constants are used by setType:
and type
.
NSCell.h
Defines a type for cell attributes.
typedef NSUInteger NSCellAttribute;
For possible values, see “Cell Attributes.”
NSCell.h
These constants specify how a button behaves when pressed and how it displays its state.
typedef enum _NSCellAttribute { 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;
NSCellAllowsMixedState
Lets the cell’s state be NSMixedState
, as well as NSOffState
and NSOnState
.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSChangeBackgroundCell
If the cell’s state is NSMixedState
or NSOnState
, changes the cell’s background color from gray to white.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSCellChangesContents
If the cell’s state is NSMixedState
or NSOnState
, displays the cell’s alternate image.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSChangeGrayCell
If the cell’s state is NSMixedState
or NSOnState
, displays the cell’s image as darkened.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSCellDisabled
Does not let the user manipulate the cell.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSCellEditable
Lets the user edit the cell’s contents.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
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 Mac OS X v10.0 and later.
Declared in NSCell.h
.
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 Mac OS X v10.0 and later.
Declared in NSCell.h
.
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 Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSCellHighlighted
Draws the cell with a highlighted appearance. (Deprecated. Use setHighlighted:
instead.)
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSCellIsBordered
Draws a border around the cell.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
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 is unbordered.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSCellLightsByBackground
If the cell is pushed in, changes the cell’s background color from gray to white.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSCellLightsByContents
If the cell is pushed in, displays the cell’s alternate image.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSCellLightsByGray
If the cell is pushed in, displays the cell’s image as darkened.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSPushInCell
Determines whether the cell’s image and text appear to be shifted down and to the right.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSCellState
The cell’s state.
The cell’s state can be NSMixedState
, NSOffState
, or NSOnState
.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
These constants are used by the NSButton
and NSButtonCell
classes:
NSCell.h
Defines a type to specify the position of an image in a cell.
typedef NSUInteger NSCellImagePosition;
For possible values, see “Image Position.”
NSCell.h
These constants specify the position of a button’s image relative to its title.
typedef enum _NSCellImagePosition { NSNoImage = 0, NSImageOnly = 1, NSImageLeft = 2, NSImageRight = 3, NSImageBelow = 4, NSImageAbove = 5, NSImageOverlaps = 6 } NSCellImagePosition;
NSNoImage
The cell doesn’t display an image.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSImageOnly
The cell displays an image, but not a title.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSImageLeft
The image is to the left of the title.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSImageRight
The image is to the right of the title.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSImageBelow
The image is below the title.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSImageAbove
The image is above the title.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSImageOverlaps
The image overlaps the title.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
These constants are used by the setImagePosition:
and imagePosition
methods of NSButton
and NSButtonCell
.
NSCell.h
Defines a type to specify the scaling behavior of an image in a cell.
typedef NSUInteger NSImageScaling;
For possible values, see “Image Scaling.”
NSCell.h
These constants specify a cell’s image scaling behavior.
enum { NSImageScaleProportionallyDown = 0, NSImageScaleAxesIndependently, NSImageScaleNone, NSImageScaleProportionallyUpOrDown };
NSImageScaleProportionallyDown
If it is too large for the destination, scale the image down while preserving the aspect ratio.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSImageScaleAxesIndependently
Scale each dimension to exactly fit destination.
This setting does not preserve the aspect ratio of the image.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSImageScaleNone
Do not scale the image.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSImageScaleProportionallyUpOrDown
Scale the image to its maximum possible dimensions while both staying within the destination area and preserving its aspect ratio.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSCell.h
These are deprecated scaling constants. (Deprecated. Use “Image Scaling” constants instead.)
enum { NSScaleProportionally = 0, NSScaleToFit, NSScaleNone };
NSScaleProportionally
Use NSImageScaleProportionallyDown
.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSScaleToFit
Use NSImageScaleAxesIndependently
.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSScaleNone
Use NSImageScaleNone
.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
Defines a type to specify the state of a cell.
typedef NSUInteger NSCellStateValue;
For possible values, see “Cell States.”
NSCell.h
These constants specify a cell’s state and are used mostly for buttons.
typedef enum _NSCellState { NSMixedState = -1, NSOffState = 0, NSOnState = 1 } NSCellStateValue;
NSMixedState
The corresponding feature is in effect somewhere.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSOffState
The corresponding feature is in effect nowhere.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSOnState
The corresponding feature is in effect everywhere.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
These constants are described in Cell States.
NSCell.h
These constants specify what happens when a button is pressed or is displaying its alternate state.
enum { NSNoCellMask = 0, NSContentsCellMask = 1, NSPushInCellMask = 2, NSChangeGrayCellMask = 4, NSChangeBackgroundCellMask = 8 };
NSNoCellMask
The button cell doesn’t change.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSPushInCellMask
The button cell “pushes in” if it has a border.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSContentsCellMask
The button cell displays its alternate icon and/or title.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSChangeGrayCellMask
The button cell swaps the “control color” (the controlColor
method of NSColor
) and white pixels on its background and icon.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSChangeBackgroundCellMask
Same as NSChangeGrayCellMask
, but only background pixels are changed.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
These contents are used by the highlightsBy
and showsStateBy
methods of NSButtonCell
.
NSCell.h
Defines a type to specify the tint of a cell.
typedef NSUInteger NSControlTint;
For possible values, see “Control Tints.”
NSCell.h
These constants specify a cell’s tint.
typedef enum _NSControlTint { NSDefaultControlTint = 0, NSBlueControlTint = 1, NSGraphiteControlTint = 6, NSClearControlTint = 7 } NSControlTint;
NSDefaultControlTint
The current default tint setting
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSClearControlTint
Clear control tint
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSBlueControlTint
Aqua control tint
Available in Mac OS X v10.3 and later.
Declared in NSCell.h
.
NSGraphiteControlTint
Graphite control tint
Available in Mac OS X v10.3 and later.
Declared in NSCell.h
.
These constants are used by controlTint
and setControlTint:
.
NSCell.h
Defines a type to specify the size of a cell.
typedef NSUInteger NSControlSize;
For possible values, see “Control Sizes.”
NSCell.h
These constants specify a cell’s size.
typedef enum _NSControlSize { NSRegularControlSize, NSSmallControlSize, NSMiniControlSize } NSControlSize;
NSRegularControlSize
The control is sized as regular.
Available in Mac OS X v10.0 and later.
Declared in NSCell.h
.
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 Mac OS X v10.0 and later.
Declared in NSCell.h
.
NSMiniControlSize
The control has a smaller size than NSSmallControlSize
.
Available in Mac OS X v10.3 and later.
Declared in NSCell.h
.
These constants are used by controlSize
and setControlSize:
.
NSCell.h
These constants are used by hitTestForEvent:inRect:ofView:
to determine the effect of an event.
enum { NSCellHitNone = 0, NSCellHitContentArea = 1 << 0, NSCellHitEditableTextArea = 1 << 1, NSCellHitTrackableArea = 1 << 2, };
NSCellHitNone
An empty area, or did not hit in the cell.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSCellHitContentArea
A content area in the cell.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSCellHitEditableTextArea
An editable text area of the cell.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSCellHitTrackableArea
A trackable area in the cell.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSCell.h
These constants specify how a cell formats numeric data.
enum { NSAnyType = 0, NSIntType = 1, NSPositiveIntType = 2, NSFloatType = 3, NSPositiveFloatType = 4, NSDoubleType = 6, NSPositiveDoubleType = 7 };
NSIntType
Must be between INT_MIN
and INT_MAX
.
Deprecated in Mac OS X v10.4 and later.
Declared in NSCell.h
.
NSPositiveIntType
Must be between 1 and INT_MAX
.
Deprecated in Mac OS X v10.4 and later.
Declared in NSCell.h
.
NSFloatType
Must be between –FLT_MAX
and FLT_MAX
.
Deprecated in Mac OS X v10.4 and later.
Declared in NSCell.h
.
NSPositiveFloatType
Must be between FLT_MIN
and FLT_MAX
.
Deprecated in Mac OS X v10.4 and later.
Declared in NSCell.h
.
NSDoubleType
Must be between –FLT_MAX
and FLT_MAX
.
Deprecated in Mac OS X v10.4 and later.
Declared in NSCell.h
.
NSPositiveDoubleType
Must be between FLT_MIN
and FLT_MAX
.
Deprecated in Mac OS X v10.4 and later.
Declared in NSCell.h
.
NSAnyType
Any value is allowed.
Deprecated in Mac OS X v10.4 and later.
Declared in NSCell.h
.
These constants are used by setEntryType:
and entryType
.
NSCell.h
Defines a type to specify the background style of a cell.
typedef NSUInteger NSBackgroundStyle;
For possible values, see “Background Styles.”
NSCell.h
Background styles used with backgroundStyle
, setBackgroundStyle:
, and interiorBackgroundStyle
.
enum { NSBackgroundStyleLight = 0, NSBackgroundStyleDark, NSBackgroundStyleRaised, NSBackgroundStyleLowered };
NSBackgroundStyleLight
The background is a light color.
Dark content contrasts well with this background.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSBackgroundStyleDark
The background is a dark color.
Light content contrasts well with this background.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSBackgroundStyleRaised
The background is intended to appear higher than the content drawn on it.
Content might need to be inset.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSBackgroundStyleLowered
The background is intended to appear lower than the content drawn on it.
Content might need to be embossed.
Available in Mac OS X v10.5 and later.
Declared in NSCell.h
.
NSCell.h
Sent after the user changes control tint preference. The notification object is NSApp
. This notification does not contain a userInfo dictionary.
NSCell.h
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-02-04)