- Inherits from:
- NSObject
- Conforms to:
- NSCoding
- NSCopying
- NSObject (NSObject)
Declared in:
- AppKit/NSCell.h
The NSCell class provides a mechanism for displaying text or images in an NSView without the overhead of a full NSView subclass. In particular, it provides much of the functionality of the NSText class by providing access to a shared NSText object used by all instances of NSCell in an application. NSCells are also extremely useful for placing text or images at various locations in a custom subclass of NSView.
NSCell is used heavily by most of the NSControl classes to implement their internal workings. For example, NSSlider uses an NSSliderCell, NSTextField uses an NSTextFieldCell, and NSBrowser uses an NSBrowserCell. Sending a message to the NSControl is often simpler than dealing directly with the corresponding NSCell. For instance, NSControls typically invoke updateCell: (causing the cell to be displayed) after changing a cell attribute; whereas if you directly call the corresponding method of the NSCell, the NSCell might not automatically display itself again.
Some subclasses of NSControl (notably NSMatrix) group NSCells in an arrangement where they act together in some cooperative manner. Thus, with an NSMatrix, you can implement a uniformly sized group of radio buttons without needing an NSView for each button (and without needing an NSText object as the field editor for the text on each button).
The NSCell class provides primitives for displaying text or an image, editing text, setting and getting object values, maintaining state, highlighting, and tracking the mouse. NSCell's method trackMouse:inRect:ofView:untilMouseUp: implements the mechanism that sends action messages to target objects. However, NSCell implements target/action features abstractly, deferring the details of implementation to NSActionCell and its subclasses.
Every NSCell that displays text has a value associated with it. The NSCell stores that value as an object of potentially any type, displays it as an NSString, and returns it as a primary value or string object, according to what's requested ( intValue, floatValue, stringValue, and so on). Formatters are objects associated with NSCells (through setFormatter:) that translate a cell's object value to its it textual representation and convert what users type into the underlying object. NSCells have built-in formatters to handle common string and numeric (int, float, double) translations. In addition, you can specify date and numeric types more precisely with setEntryType: and specify floating-point format characteristics with setFloatingPointFormat:left:right:. You can also implement your own formatters to provide specialized object translation; see the NSFormatter specification for more information.
The text that an NSCell displays and stores can be an attributed string. Several methods help to set and get attributed-string values, including setAttributedStringValue: and setImportsGraphics:.
For some subclasses of NSCell, such as an NSButtonCell, the
object's value is its state. It can have either two states-NSOnState
and NSOffState
-or
three states-NSOnState
, NSOffState
,
and NSMixedState
. A mixed state is
useful for a checkbox or radio button that reflects the status of
a feature. For example, suppose there's a checkbox that makes
the selected text bold. If all the selected text is bold, it's
on. If none of the selected text is bold, it's off. If the text
has a combination of bold and plain text, it's mixed. Now suppose
you click the checkbox. If you turn it on, all the text becomes
bold. If you turn it off, all the text becomes plain. If you select
the mixed state, the text remains as it is.
By default, an NSCell has two states. You can allow the third state with the method setAllowsMixedState:. To set the button's state directly, use setState:. To cycle through all available states, use setNextState.
Represented objects are objects an NSCell stands for. (They're not to be confused with an NSCell's object value, which is the value of the cell.) By setting a represented object for an NSCell (using setRepresentedObject:) you make an association between the NSCell and that object. For instance, you could have a pop-up list, each cell of which lists a color as its title; when the user selects a cell, the represented NSColor object is displayed in a color well. This feature is solely for the developer's convenience. The cell itself does not use the represented object, except to archive and restore it.
The initImageCell: method is the designated initializer for NSCells that display images. The initTextCell: method is the designated initializer for NSCells that display text. Override one or both of these methods if you implement a subclass of NSCell that performs its own initialization. If you need to use target and action behavior, you may prefer to subclass NSActionCell or one of its subclasses, which provide the default implementation of this behavior.
If you want to implement your own mouse-tracking or mouse-up behavior, consider overriding startTrackingAt:inView:, continueTracking:at:inView:, and stopTracking:at:inView:mouseIsUp:. If you want to implement your own drawing, override drawWithFrame:inView: or drawInteriorWithFrame:inView:.
If the subclass contains instance variables that hold pointers to objects, consider overriding copyWithZone: to duplicate the objects. The default version copies only pointers to the objects.
For more information on how NSCell is used, see the NSControl class specification.
These constants specify how a cell formats numeric data. They're used by setEntryType: and entryType
Constant | Restrictions and Other Information |
NSIntType |
Must be between INT_MIN and INT_MAX |
NSPositiveIntType |
Must be between 1 and INT_MAX |
NSFloatType |
Must be between -FLT_MAX and FLT_MAX |
NSPositiveFloatType |
Must be between FLT_MIN and FLT_MAX |
NSDoubleType |
Must be between -DBL_MAX and DBL_MAX |
NSPositiveDoubleType |
Must be between DBL_MAX and DBL_MAX |
NSAnyType |
Any value is allowed. |
These constants specify what a cell contains. They're used by setType: and type.
Constant | Description |
NSNullCellType |
Description forthcoming. |
NSTextCellType |
Description forthcoming. |
NSImageCellType |
Description forthcoming. |
These constants specify how a button behaves when pressed and how it displays its state They're used by NSButton and NSButtonCell:
Constant | Description |
NSCellDisabled |
Description forthcoming. |
NSCellState |
Description forthcoming. |
NSPushInCell |
Description forthcoming. |
NSCellEditable |
Description forthcoming. |
NSChangeGrayCell |
Description forthcoming. |
NSCellHighlighted |
Description forthcoming. |
NSCellLightsByContents |
Description forthcoming. |
NSCellLightsByGray |
Description forthcoming. |
NSChangeBackgroundCell |
Description forthcoming. |
NSCellLightsByBackground |
Description forthcoming. |
NSCellIsBordered |
Description forthcoming. |
NSCellHasOverlappingImage |
Description forthcoming. |
NSCellHasImageHorizontal |
Description forthcoming. |
NSCellHasImageOnLeftOrBottom |
Description forthcoming. |
NSCellChangesContents |
Description forthcoming. |
NSCellIsInsetButton |
Description forthcoming. |
NSCellAllowsMixedState |
Description forthcoming. |
These constants specify the position of a button's image relative to its title. They're used by NSButton's and NSButtonCell's setImagePosition: and imagePosition.
Constant | Description |
NSNoImage |
The cell doesn't display an image |
NSImageOnly |
The cell displays an image, but not a title |
NSImageLeft |
The image is to the left of the title |
NSImageRight |
The image is to the right of the title |
NSImageBelow |
The image is below the title |
NSImageAbove |
The image is above the title |
NSImageOverlaps |
The image overlaps the title |
These constants specify a cell's state and are used mostly for buttons. They're described in "Cell States" .
Constant | Description |
NSMixedState |
The corresponding feature is in effect somewhere. |
NSOffState |
The corresponding feature is in effect nowhere. |
NSOnState |
The corresponding feature is in effect everywhere. |
These constants specify what happens when a button is pressed or is displaying its alternate state. They're used by NSButtonCell's highlightsBy and showsStateBy.
Constant | Description |
NSNoCellMask |
The button cell doesn't change. |
NSPushInCellMask |
The button cell "pushes in" if it has a border. |
NSContentsCellMask |
The button cell displays its alternate icon and/or title. |
NSChangeGrayCellMask |
The button cell swaps the "control color" (NSColor's controlColor) and white pixels on the its background and icon. |
NSChangeBackgroundCellMask |
Same as NSChangeGrayCellMask ,
but only background pixels are changed. |
- Initializing an NSCell
- - initImageCell:
- - initTextCell:
- Setting and getting cell values
- - setObjectValue:
- - objectValue
- - hasValidObjectValue
- - setIntValue:
- - intValue
- - setStringValue:
- - stringValue
- - setDoubleValue:
- - doubleValue
- - setFloatValue:
- - floatValue
- Setting and getting cell attributes
- - setCellAttribute:to:
- - cellAttribute:
- - setType:
- - type
- - setEnabled:
- - isEnabled
- - setBezeled:
- - isBezeled
- - setBordered:
- - isBordered
- - isOpaque
- Setting the state
- - allowsMixedState
- - nextState
- - setAllowsMixedState:
- - setNextState
- - setState:
- - state
- Modifying textual attributes of cells
- - setEditable:
- - isEditable
- - setSelectable:
- - isSelectable
- - setScrollable:
- - isScrollable
- - setAlignment:
- - alignment
- - setFont:
- - font
- - setWraps:
- - wraps
- - setAttributedStringValue:
- - attributedStringValue
- - setAllowsEditingTextAttributes:
- - allowsEditingTextAttributes
- - setImportsGraphics:
- - importsGraphics
- - setUpFieldEditorAttributes:
- Setting the target and action
- - setAction:
- - action
- - setTarget:
- - target
- - setContinuous:
- - isContinuous
- - sendActionOn:
- Setting and getting an image
- - setImage:
- - image
- Assigning a tag
- - setTag:
- - tag
- Formatting and validating data
- - setFormatter:
- - formatter
- - setEntryType:
- - entryType
- - isEntryAcceptable:
- - setFloatingPointFormat:left:right:
- Managing menus for cells
- + defaultMenu
- - setMenu:
- - menu
- - menuForEvent:inRect:ofView:
- Comparing cells
- - compare:
- Making cells respond to keyboard events
- - acceptsFirstResponder
- - setShowsFirstResponder:
- - showsFirstResponder
- - setTitleWithMnemonic:
- - mnemonic
- - refusesFirstResponder
- - setMnemonicLocation:
- - setRefusesFirstResponder:
- - mnemonicLocation
- - performClick:
- Deriving values from other cells
- - takeObjectValueFrom:
- - takeIntValueFrom:
- - takeStringValueFrom:
- - takeDoubleValueFrom:
- - takeFloatValueFrom:
- Representing an object with a cell
- - setRepresentedObject:
- - representedObject
- Tracking the mouse
- - trackMouse:inRect:ofView:untilMouseUp:
- - startTrackingAt:inView:
- - continueTracking:at:inView:
- - stopTracking:at:inView:mouseIsUp:
- - mouseDownFlags
- + prefersTrackingUntilMouseUp
- - getPeriodicDelay:interval:
- Managing the cursor
- - resetCursorRect:inView:
- Handling keyboard alternatives
- - keyEquivalent
- Determining cell sizes
- - calcDrawInfo:
- - cellSize
- - cellSizeForBounds:
- - drawingRectForBounds:
- - imageRectForBounds:
- - titleRectForBounds:
- Drawing and highlighting cells
- - drawWithFrame:inView:
- - drawInteriorWithFrame:inView:
- - controlView
- - highlight:withFrame:inView:
- - isHighlighted
- Editing and selecting cell text
- - editWithFrame:inView:editor:delegate:event:
- - selectWithFrame:inView:editor:delegate:start:length:
- - sendsActionOnEndEditing
- - setSendsActionOnEndEditing:
- - endEditing:
+ (NSMenu *)defaultMenu
nil
.See Also: - menu, - setMenu:
+ (BOOL)prefersTrackingUntilMouseUp
NO
, so tracking stops when
the mouse leaves the NSCell; subclasses may override.See Also: - trackMouse:inRect:ofView:untilMouseUp:
- (BOOL)acceptsFirstResponder
YES
if the
cell is enabled and refusesFirstResponder returns NO
;
subclasses can override.See Also: - performClick:, - setShowsFirstResponder:, - setTitleWithMnemonic:
- (SEL)action
See Also: - setAction:, - setTarget:, - target
- (NSTextAlignment)alignment
NSLeftTextAlignment
, NSRightTextAlignment
, NSCenterTextAlignment
, NSJustifiedTextAlignment
,
or NSNaturalTextAlignment
.See Also: - setAlignment:
- (BOOL)allowsEditingTextAttributes
See Also: - setAllowsEditingTextAttributes:
- (BOOL)allowsMixedState
YES
if
the button has three states: on, off, and mixed. Returns NO
if
the button has two states: on and off. See Also: - nextState, - setAllowsMixedState:, - setNextState
- (NSAttributedString *)attributedStringValue
See Also: - setAttributedStringValue:
- (void)calcDrawInfo:(NSRect)aRect
See Also: - cellSize, - drawingRectForBounds:
- (int)cellAttribute:(NSCellAttribute)aParameter
See Also: - setCellAttribute:to:
- (NSSize)cellSize
See Also: - drawingRectForBounds:
- (NSSize)cellSizeForBounds:(NSRect)aRect
See Also: - drawingRectForBounds:
- (NSComparisonResult)compare:(id)otherCell
- (BOOL)continueTracking:(NSPoint)lastPoint
at:(NSPoint)currentPoint
inView:(NSView *)controlView
YES
if
the cell is set to continuously send action messages to its target
when the mouse is down or is being dragged. Subclasses can override
this method to provide more sophisticated tracking behavior.See Also: - startTrackingAt:inView:, - stopTracking:at:inView:mouseIsUp:
- (NSView *)controlView
nil
.See Also: - drawWithFrame:inView:
- (double)doubleValue
- (void)drawInteriorWithFrame:(NSRect)cellFrame
inView:(NSView *)controlView
Subclasses often override this method to provide more sophisticated drawing of cell contents. Because drawWithFrame:inView: invokes drawInteriorWithFrame:inView:: after it draws the NSCell's border, don't invoke drawWithFrame:inView: in your override implementation.
See Also: - isHighlighted, - setShowsFirstResponder:
- (void)drawWithFrame:(NSRect)cellFrame
inView:(NSView *)controlView
- (NSRect)drawingRectForBounds:(NSRect)theRect
See Also: - calcSize (NSControl)
- (void)editWithFrame:(NSRect)aRect
inView:(NSView *)controlView
editor:(NSText *)textObj
delegate:(id)anObject
event:(NSEvent *)theEvent
NSLeftMouseDown
event. anObject is
made the delegate of textObj, and
so will receive various NSText delegation and notification messages.If the receiver isn't a text-type NSCell, no editing is performed. Otherwise, textObj is sized to aRect and its superview is set to aView, so it exactly covers the NSCell. Then it's activated and editing begins. It's the responsibility of the delegate to end editing when responding to textShouldEndEditing:. In doing this, it should remove any data from textObj.
See Also: - endEditing:, - selectWithFrame:inView:editor:delegate:start:length:
- (void)endEditing:(NSText
*)textObj
- (int)entryType
NSAnyType
is
returned. See setEntryType: for
a list of type constants.See Also: - isEntryAcceptable:
- (float)floatValue
- (NSFont *)font
nil
if
the receiver is not a text-type cell.See Also: - setFont:
- (id)formatter
See Also: - setFormatter:
- (void)getPeriodicDelay:(float
*)delay
interval:(float *)interval
See Also: - isContinuous, - setContinuous:
- (BOOL)hasValidObjectValue
See Also: - objectValue, - setObjectValue:
- (void)highlight:(BOOL)flag
withFrame:(NSRect)cellFrame
inView:(NSView *)controlView
YES
, highlights
the rectangle cellFrame in the NSControl
(controlView).Note that NSCell's 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.
See Also: - drawWithFrame:inView:, - isHighlighted
- (NSImage *)image
nil
if
the receiver is not an image-type cell.See Also: - setImage:
- (NSRect)imageRectForBounds:(NSRect)theRect
See Also: - cellSizeForBounds:, - drawingRectForBounds:
- (BOOL)importsGraphics
See Also: - setImportsGraphics:
- (id)initImageCell:(NSImage
*)anImage
nil
,
no image is set.- (id)initTextCell:(NSString
*)aString
- (int)intValue
- (BOOL)isBezeled
See Also: - setBezeled:
- (BOOL)isBordered
See Also: - setBordered:
- (BOOL)isContinuous
See Also: - setContinuous:
- (BOOL)isEditable
See Also: - setEditable:
- (BOOL)isEnabled
See Also: - setEnabled:
- (BOOL)isEntryAcceptable:(NSString
*)aString
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. |
See Also: - entryType, - setEntryType:
- (BOOL)isHighlighted
- (BOOL)isOpaque
- (BOOL)isScrollable
See Also: - setScrollable:
- (BOOL)isSelectable
See Also: - setSelectable:
- (NSString *)keyEquivalent
- (NSMenu *)menu
nil
if
no menu is associated.See Also: - setMenu:
- (NSMenu *)menuForEvent:(NSEvent
*)anEvent
inRect:(NSRect)cellFrame
ofView:(NSView *)aView
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.- (NSString *)mnemonic
See Also: - setTitleWithMnemonic:
- (unsigned)mnemonicLocation
NSNotFound
.See Also: - setMnemonicLocation:
- (int)mouseDownFlags
See Also: - modifierFlags (NSEvent)
- (int)nextState
See Also: - allowsMixedState, - setAllowsMixedState:, - setNextState
- (id <NSCopying>)objectValue
nil
. To
be valid, the cell must have a formatter capable of converting the object
to and from its textual representation.- (void)performClick:(id)sender
- (BOOL)refusesFirstResponder
YES
if
the cell can never become the first responder. To
find out whether the cell can become first responder at this time,
use the method acceptsFirstResponder.See Also: - setRefusesFirstResponder:
- (id)representedObject
See Also: - setRepresentedObject:
- (void)resetCursorRect:(NSRect)cellFrame
inView:(NSView *)controlView
- (void)selectWithFrame:(NSRect)aRect
inView:(NSView *)controlView
editor:(NSText *)textObj
delegate:(id)anObject
start:(int)selStart
length:(int)selLength
nil
,
or if the receiver has no font set for it.- (int)sendActionOn:(int)mask
Value | Description |
NSLeftMouseUpMask |
Don't send action message on (left) mouse up. |
NSLeftMouseDownMask |
Send action message on (left) mouse down. |
NSLeftMouseDraggedMask |
Send action message when (left) mouse is dragged. |
NSPeriodicMask |
Send action message continuously. |
You can use setContinuous: to
turn on the flag corresponding to NSPeriodicMask
or NSLeftMouseDraggedMask
,
whichever is appropriate to the given subclass of NSCell.
See Also: - action
- (BOOL)sendsActionOnEndEditing
YES
,
the cell sends its action message when the user does one of the
following:This behavior is familiar to Mac OS users.
If it returns NO
,
the cell sends its action message only when the user presses the
Return key.
- (void)setAction:(SEL)aSelector
See Also: - action, - setTarget:, - target
- (void)setAlignment:(NSTextAlignment)mode
NSLeftTextAlignment
, NSRightTextAlignment
, NSCenterTextAlignment
, NSJustifiedTextAlignment
, NSNaturalTextAlignment
(the
default alignment for the text).See Also: - alignment, - setWraps:
- (void)setAllowsEditingTextAttributes:(BOOL)flag
NO
,
the receiver also cannot import graphics (that is, it does not support
RTFD text).See Also: - allowsEditingTextAttributes, - setImportsGraphics:
- (void)setAllowsMixedState:(BOOL)flag
YES
,
the button has three states: on, off, and mixed. If flag is NO
,
the button has two states: on and off. See Also: - allowsMixedState, - nextState, - setNextState
- (void)setAttributedStringValue:(NSAttributedString
*)attribStr
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]];
See Also: - attributedStringValue
- (void)setBezeled:(BOOL)flag
See Also: - isBezeled
- (void)setBordered:(BOOL)flag
See Also: - isBordered
- (void)setCellAttribute:(NSCellAttribute)aParameter
to:(int)value
See Also: - cellAttribute:
- (void)setContinuous:(BOOL)flag
See Also: - isContinuous, - sendActionOn:
- (void)setDoubleValue:(double)aDouble
See Also: - doubleValue
- (void)setEditable:(BOOL)flag
YES
,
the text can also be selected. If flag is NO
,
the selectable attribute is restored to what it was before the cell
was last made editable.See Also: - isEditable, - setSelectable:
- (void)setEnabled:(BOOL)flag
See Also: - isEnabled
- (void)setEntryType:(int)aType
Constant | Restrictions and Other Information |
NSIntType |
Must be between INT_MIN and INT_MAX |
NSPositiveIntType |
Must be between 1 and INT_MAX |
NSFloatType |
Must be between -FLT_MAX and FLT_MAX |
NSPositiveFloatType |
Must be between FLT_MIN and FLT_MAX |
NSDoubleType |
Must be between -DBL_MAX and DBL_MAX |
NSPositiveDoubleType |
Must be between DBL_MAX and DBL_MAX |
NSAnyType |
Any value is allowed. |
If the receiver isn't a text-type cell, this method converts it to one; in the process, it makes its title "Cell" and sets its font to the user's system font at 12 points.
You can check whether formatted strings conform to the entry types of cells with the isEntryAcceptable: method. NSControl subclasses also use isEntryAcceptable: to validate what users have typed in editable cells. You can control the format of values accepted and displayed in cells by creating a custom subclass of NSFormatter and associating an instance of that class with cells (through setFormatter:). In custom NSCell subclasses, you can also override isEntryAcceptable: to check for the validity of data entered into cells.
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. |
See Also: - entryType
- (void)setFloatingPointFormat:(BOOL)autoRange
left:(unsigned)leftDigits
right:(unsigned)rightDigits
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. |
See Also: - setEntryType:
- (void)setFloatValue:(float)aFloat
See Also: - floatValue
- (void)setFont:(NSFont
*)fontObj
nil
and
the receiver is a text-type cell, the font currently held by the
receiver is autoreleased.See Also: - font
- (void)setFormatter:(NSFormatter
*)newFormatter
nil
,
the receiver is disassociated from the current formatter.See Also: - formatter
- (void)setImage:(NSImage
*)image
nil
and
the receiver is an image-type cell, the image currently held by
the receiver is autoreleased.See Also: - image
- (void)setImportsGraphics:(BOOL)flag
YES
,
the receiver is also set to allow editing of text attributes ( setAllowsEditingTextAttributes:).See Also: - importsGraphics
- (void)setIntValue:(int)anInt
See Also: - intValue
- (void)setMenu:(NSMenu
*)aMenu
nil
,
any association with a previous menu is removed.See Also: - menu
- (void)setMnemonicLocation:(unsigned)location
See Also: - mnemonicLocation
- (void)setNextState
See Also: - allowsMixedState, - nextState, - setAllowsMixedState:
- (void)setObjectValue:(id)object
See Also: - objectValue, - setRepresentedObject:
- (void)setRefusesFirstResponder:(BOOL)flag
YES
,
the cell cannot 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
- (void)setObjectValue:(id
<NSCopying>)anObject
See Also: - setObjectValue:, - representedObject
- (void)setScrollable:(BOOL)flag
YES
,
wrapping is turned off. When the scrollable attribute is turned
on, the alignment of text in the cell is changed to left alignment.See Also: - isScrollable
- (void)setSelectable:(BOOL)flag
See Also: - isSelectable, - setEditable:
- (void)setSendsActionOnEndEditing:(BOOL)flag
YES
,
the cell sends its action message when the user does one of the
following:This behavior is familiar to Mac OS users.
If flag is NO
,
the cell sends its action message only when the user presses the
Return key.
- (void)setShowsFirstResponder:(BOOL)flag
See Also: - showsFirstResponder
- (void)setState:(int)value
NSOnState
, NSOffState
,
or NSMixedState.The
cell can have two or three states. If it has two, value can
be NSOffState
(the normal or unpressed state)
or NSOnState
(the alternate or pressed
state). If it has three, value can
be NSOnState
(the feature is in effect
everywhere), NSOffState
(the feature
is in effect nowhere), or NSMixedState (the
feature is in effect somewhere). Note that if the cell has only
two states and value is NSMixedState,
this method sets the cell's state to NSOnState
.
Although
using the enumerated constants is preferred, value can
also be an integer. If the cell has two states, zero is treated
as NSOffState
, and a non-zero value
is treated as NSOnState
. If the cell
has three states, zero 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 setState:.
To check whether the cell has three states (and uses the mixed state), invoke the method allowsMixedState.
See Also: - state
- (void)setStringValue:(NSString
*)aString
See Also: - stringValue
- (void)setTag:(int)anInt
See Also: - tag
- (void)setTarget:(id)anObject
See Also: - target
- (void)setTitleWithMnemonic:(NSString
*)aString
[aCell setTitleWithMnemonic:NSLocalizedString(@"Re&ceive")];
See Also: - mnemonic, - setMnemonicLocation:
- (void)setType:(NSCellType)aType
NSTextCellType
, NSImageTypeCell
,
or NSNullCellType
. If aType is NSTextCellType
,
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 NSImageTypeCell
,
sets a nil
image.See Also: - type
- (NSText *)setUpFieldEditorAttributes:(NSText
*)textObj
- (void)setWraps:(BOOL)flag
YES
, then
it also sets the receiver to be non-scrollable.See Also: - wraps
- (BOOL)showsFirstResponder
See Also: - setShowsFirstResponder:
- (BOOL)startTrackingAt:(NSPoint)startPoint
inView:(NSView *)controlView
YES
if the receiver is set
to respond continuously or when the mouse is dragged. Subclasses
override this method to implement special mouse-tracking behavior
at the beginning of mouse tracking-for example, displaying a special
cursor. See Also: - continueTracking:at:inView:, - stopTracking:at:inView:mouseIsUp:
- (int)state
NSOffState
(the
normal or unpressed state) or NSOnState
(the
alternate or pressed state). If it has three, it returns NSOnState
(the
feature is in effect everywhere), NSOffState
(the
feature is in effect nowhere), or NSMixedState
(the
feature is in effect somewhere).To check whether the button uses the mixed state, use the method allowsMixedState.
Note that the value state returns may not be the same value you passed into setState:.
See Also: - setState:
- (void)stopTracking:(NSPoint)lastPoint
at:(NSPoint)stopPoint
inView:(NSView *)controlView
mouseIsUp:(BOOL)flag
YES
). lastPoint is
the point the mouse was at and stopPoint is
its current point. controlView is
the NSControl managing the receiver. NSCell's default implementation
does nothing. Subclasses often override this method to provide customized
tracking behavior. The following example increments the state of
a tri-state cell when the mouse is clicked.- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag { if (flag == YES) { [self setTriState:([self triState]+1)]; } }
See Also: - startTrackingAt:inView:, - stopTracking:at:inView:mouseIsUp:
- (NSString *)stringValue
See Also: - setStringValue:
- (int)tag
See Also: - setTag:
- (void)takeDoubleValueFrom:(id)sender
See Also: - setDoubleValue:
- (void)takeFloatValueFrom:(id)sender
See Also: - setFloatValue:
- (void)takeIntValueFrom:(id)sender
- (void)sliderMoved:(id)sender { [[valueField cell] takeIntValueFrom:[sender cell]]; [valueField display]; }
See Also: - setIntValue:
- (void)takeObjectValueFrom:(id)sender
See Also: - setObjectValue:
- (void)takeStringValueFrom:(id)sender
See Also: - setStringValue:
- (id)target
nil
.See Also: - setTarget:
- (NSRect)titleRectForBounds:(NSRect)theRect
See Also: - imageRectForBounds:
- (BOOL)trackMouse:(NSEvent
*)theEvent
inRect:(NSRect)cellFrame
ofView:(NSView *)controlView
untilMouseUp:(BOOL)untilMouseUp
YES
, this
method returns YES
if the mouse goes
up anywhere; NO
, otherwise. If that
flag is set to NO
, this method returns YES
if
the mouse goes up within cellFrame; NO
,
otherwise. The argument theEvent is
typically the mouse event received by the initiating NSControl,
usually identified by controlView.
The untilMouseUp argument indicates whether
tracking should continue until the mouse button goes up; if it's NO
,
tracking ends when the mouse is dragged after the initial mouse
down.This method first invokes startTrackingAt:inView:. If that
method returns YES
, then as mouse-dragged
events are intercepted, continueTracking:at:inView: is
invoked. Finally, stopTracking:at:inView:mouseIsUp: is
invoked. If untilMouseUp is YES
,
it's invoked when the mouse goes up anywhere, If untilMouseUp is NO
,
it's invoked when the mouse goes up within cellFrame.
(If cellFrame is nil
,
then the bounds are considered infinitely large.) You usually override
one or more of these methods to respond to specific mouse events.
- (NSCellType)type
NSTextCellType
, NSImageTypeCell
,
or NSNullCellType
.See Also: - setType:
- (BOOL)wraps
See Also: - setWraps: