Inherits from: NSTextFieldCell : NSActionCell : NSCell : NSObject
Conforms to: NSObject
(from NSObject)
NSCoding (from NSCell)
NSCopying (from NSCell)
Declared in: AppKit/NSComboBoxCell.h
NSComboBoxCell is a subclass of NSTextFieldCell used to implement the user interface of "combo boxes" (see the Class Description in the NSComboBox class specification for information on how combo boxes look and work). The NSComboBox subclass of NSTextField uses a single NSComboBoxCell, and essentially all of NSComboBox's methods simply invoke the corresponding NSComboBoxCell method.
- Setting display attributes
- - hasVerticalScroller
- - intercellSpacing
- - itemHeight
- - numberOfVisibleItems
- - setHasVerticalScroller:
- - setIntercellSpacing:
- - setItemHeight:
- - setNumberOfVisibleItems:
- Setting a data source
- - dataSource
- - setDataSource:
- - setUsesDataSource:
- - usesDataSource
- Working with an internal list
- - addItemsWithObjectValues:
- - addItemWithObjectValue:
- - insertItemWithObjectValue:atIndex:
- - objectValues
- - removeAllItems
- - removeItemAtIndex:
- - removeItemWithObjectValue:
- - numberOfItems
- Manipulating the displayed list
- - indexOfItemWithObjectValue:
- - itemObjectValueAtIndex:
- - noteNumberOfItemsChanged
- - reloadData
- - scrollItemAtIndexToTop:
- - scrollItemAtIndexToVisible:
- Manipulating the selection
- - deselectItemAtIndex:
- - indexOfSelectedItem
- - objectValueOfSelectedItem
- - selectItemAtIndex:
- - selectItemWithObjectValue:
- Completing the text field
- - completedString:
- - completes
- - setCompletes:
- (void)addItemsWithObjectValues:(id)objects
YES
.- (void)addItemWithObjectValue:(id)anObject
YES
.- (NSString *)completedString:(NSString
*)substring
nil
if there is no such string. The
argument substring is what the user
entered in the combo box's text field. The default implementation
of this method first checks whether the combo box uses a data source
and whether the data source responds to comboBox:completedString: or comboBoxCell:completedString:. If
so, the combo box cell returns that method's return value. Otherwise,
this method goes through the combo box's items one-by-one and
returns an item which starts with substring. Override this method only if your subclass completes strings differently. The overriding method does not need to call the superclass's method. Generally, you do not need to call this method directly.
- (BOOL)completes
YES
if
the combo box tries to complete what the user types in the text field. It
returns NO
otherwise.See Also: setCompletes:
- (id)dataSource
NO
.
See the class description and the NSComboBoxCellDataSource informal
protocol specification for more information on combo box cell data
source objects.- (void)deselectItemAtIndex:(int)index
See Also: - indexOfSelectedItem, - numberOfItems, - selectItemAtIndex:
- (void)encodeWithCoder:(NSCoder
*)encoder
See Also: - initWithCoder:
- (BOOL)hasVerticalScroller
YES
if
the receiver will display a vertical scroller. Note
that the scoller will be displayed even if the pop-up list contains
fewer items than will fit in the area specified for display. Returns NO
if
the receiver won't display a vertical scroller.See Also: - numberOfItems, - numberOfVisibleItems
- (int)indexOfItemWithObjectValue:(id)anObject
YES
.
If none of the objects in the receiver's internal item list are
equal to anObject, indexOfItemWithObjectValue: returns NSNotFound.
This method logs a warning if usesDataSource returns YES
.See Also: - selectItemWithObjectValue:
- (int)indexOfSelectedItem
See Also: - objectValueOfSelectedItem
- (id)initWithCoder:(NSCoder
*)decoder
See Also: - encodeWithCoder:
- (void)insertItemWithObjectValue:(id)anObject atIndex:(int)index
YES
.See Also: - addItemWithObjectValue:, - numberOfItems
- (NSSize)intercellSpacing
See Also: - itemHeight, - numberOfVisibleItems
- (float)itemHeight
See Also: - intercellSpacing, - numberOfVisibleItems
- (id)itemObjectValueAtIndex:(int)index
YES
. See Also: - objectValueOfSelectedItem
- (void)noteNumberOfItemsChanged
See the NSComboBoxCellDataSource informal protocol specification for information on the messages an NSComboBoxCell sends to its data source.
See Also: - reloadData
- (int)numberOfItems
See Also: - numberOfVisibleItems, - numberOfItemsInComboBoxCell: (NSComboBoxCellDataSource protocol), -
- (int)numberOfVisibleItems
See Also: - numberOfItems
- (id)objectValueOfSelectedItem
YES
.See Also: - indexOfSelectedItem, - comboBoxCell:objectValueForItemAtIndex: (NSComboBoxCellDataSource protocol)
- (NSArray *)objectValues
YES
.- (void)reloadData
See Also: - noteNumberOfItemsChanged
- (void)removeAllItems
YES
.See Also: - objectValues
- (void)removeItemAtIndex:(int)index
YES
.- (void)removeItemWithObjectValue:(id)anObject
YES
.
This method logs a warning if usesDataSource returns YES
.See Also: - indexOfItemWithObjectValue:
- (void)scrollItemAtIndexToTop:(int)index
- (void)scrollItemAtIndexToVisible:(int)index
- (void)selectItemAtIndex:(int)index
See Also: - setObjectValue:(NSControl)
- (void)selectItemWithObjectValue:(id)anObject
YES
.
Posts NSComboBoxSelectionDidChangeNotification to the default notification
center if the selection does in fact change. Note that this method
doesn't alter the contents of the combo box cell's text field-see "Interacting
with the Text Field" in the class description for more information.See Also: - setObjectValue:(NSControl)
- (void)setCompletes:(BOOL)completes
If completes is YES
,
every time the user adds characters to the end of the text field,
the combo box calls the NSComboBoxCell method completedString:. If completedString: returns
a string that's longer than the existing string, the combo box
replaces the existing string with the returned string, and selects
the additional characters. If the user is deleting characters or
adds characters somwhere besides the end of the string, the combo
box does not try to complete it.
See Also: completes
- (void)setDataSource:(id)aSource
NO
,
and in fact logs a warning if usesDataSource returns NO
.This method logs a warning if aSource doesn't respond to either numberOfRowsInComboBoxCell: or comboBoxCell:objectValueForItemAtIndex:.
See Also: - setUsesDataSource:
- (void)setHasVerticalScroller:(BOOL)flag
YES
.
If flag is NO
and
the combo box cell has more list items (either in its internal item
list or from its data source) than are allowed by numberOfVisibleItems,
only a subset will be displayed. NSComboBoxCell's scroll... methods
can be used to position this subset within the pop-up list.Note
that if flag is YES
,
a scroller will be displayed even if the combo box cell has fewer
list items than are allowed by numberOfVisibleItems.
See Also: - numberOfItems, - scrollItemAtIndexToTop:, - scrollItemAtIndexToVisible:
- (void)setIntercellSpacing:(NSSize)aSize
See Also: - setItemHeight:, - setNumberOfVisibleItems:
- (void)setItemHeight:(float)itemHeight
See Also: - setIntercellSpacing:, - setNumberOfVisibleItems:
- (void)setNumberOfVisibleItems:(int)visibleItems
See Also: - numberOfItems, - numberOfVisibleItems, - setIntercellSpacing:, - setItemHeight:
- (void)setUsesDataSource:(BOOL)flag
- (BOOL)usesDataSource
YES
if
the receiver uses an external data source to populate the receiver's
pop-up list, NO
if
it uses an internal item list.See Also: - dataSource