- Inherits from:
- NSView : NSResponder : NSObject
The list view presents long lists of data in snaking columns that will scroll horizontally, if necessary. The user can select individual data items by clicking, or by using the complete set of navigation keys. When the user clicks on an item, an action message can be sent, double-clicking will lead to an alternative message. Double-clicking an item can also open it for editing, if required.
As shown above, it is possible to use a custom cell instead of the default NSTextFieldCell. Odd columns can be highlighted. Vertical intercell spacing can be included, optionally displaying grid lines. Individual cells can be highlighted or show a background color, with the help of delegate methods. Formatting is partially supported.
Setting the data sourceLoading data
- - setDataSource:
- - dataSource
Target-action behavior
- - reloadData
Configuring behavior
- - setTarget:
- - target
- - setAction:
- - action
- - setDoubleAction:
- - doubleAction
Setting display attributes
- - setAllowsSelection:
- - allowsSelection
Setting grid attributes
- - setIntercellSpacing:
- - intercellSpacing
- - setRowHeight:
- - rowHeight
- - setColumnWidth:
- - columnWidth
- - setHighlightOddColumns:
- - highlightOddColumns
- - setBackgroundColor:
- - backgroundColor
Selecting cells
- - setDrawsGrid:
- - drawsGrid
- - setGridColor:
- - gridColor
Getting the dimensions of the table
- - indexOfSelectedCell
- - selectCellAtIndex:
Editing cells
- - numberOfColumns
- - numberOfRows
Layout support
- - setIsEditable:
- - isEditable
- - editCellAtIndex:
Scrolling
- - frameOfCellAtPoint:
- - frameOfCellAtIndex:
- - cellIndexAtPoint:
- - columnAtIndex:
- - rectOfColumn:
Text delegate methods
- - scrollColumnToVisible:
- - scrollToSelection
Assigning a delegate
- - textDidChange:
- - textShouldEndEditing:
- - textDidEndEditing:
Formatting text
- - setDelegate:
- - delegate
Methods implemented by the data source
- - alignment
- - setAlignment:
- - formatter
- - setFormatter:
Methods implemented by the delegate
- - numberOfObjectsInListView:
- - listView:objectValueAtIndex:
- - listView:setObjectValue:atIndex:
Notifications
- listView:willDisplayCell:atIndex:
- listView:shouldEditCell:atIndex:
- listView:shouldSelectCell:atIndex:
- listView:textShouldEndEditing:
- listView:didFailToFormatString:errorDescription:
- listView:didFailToValidatePartialString:errorDescription:
- listView:textView:doCommandBySelector:
- SSListViewSelectionIsChangingNotification
- SSListViewSelectionDidChangeNotification
- SSListViewTextDidEndEditingNotification
- (SEL)action
See Also: - doubleAction, - target, - setAction:
- (NSTextAlignment)alignment
NSLeftTextAlignment
, NSRightTextAlignment
, NSCenterTextAlignment
, NSJustifiedTextAlignment
, or NSNaturalTextAlignment
.See Also: - setAlignment:
- (BOOL)allowsSelection
YES
if the receiver allows the user to select a cell, NO
otherwise. The default is NO
.
You can select a cell programmatically even if this setting is NO
.
See Also: - setAllowsSelection:
- (int)cellIndexAtPoint:(NSPoint)aPoint
- (int)columnAtIndex:(int)index
See Also: - rectOfColumn:
- (id)dataSource
See Also: - setDataSource:
- (id)delegate
See Also: - setDelegate:
- (id)formatter
See Also: - setFormatter:
- (SEL)doubleAction
See Also: - action, - target, - setDoubleAction:
- (BOOL)drawsGrid
YES
if the receiver draws grid lines between cells, NO
if it doesn't. The default is NO
.See Also: - gridColor, - setDrawsGrid:
- (void)editCellAtIndex:(int)index
This method scrolls the receiver so that the cell is visible, sets up the field editor, and sends selectWithFrame:inView:editor:delegate:start:length:
to the field editor's NSCell object with the receiver as the text delegate.
See Also: - isEditable, - setIsEditable:
- (NSRect)frameOfCellAtIndex:(int)index
See Also: - frameOfCellAtPoint:, - cellIndexAtPoint:
- (NSRect)frameOfCellAtPoint:(NSPoint)aPoint
NSZeroRect
if aPoint lies
below the area of valid cells of the receiver.See Also: - frameOfCellAtIndex:, - cellIndexAtPoint:
- (NSColor *)gridColor
See Also: - drawsGrid, - setGridColor:
- (int)indexOfSelectedCell
See Also: - selectCellAtIndex:
- (NSSize)intercellSpacing
See Also: - setDrawsGrid:, - setIntercellSpacing:
- (BOOL)isEditable
YES
if the selected cell is editable, NO
if it doesn't. The default is NO
.See Also: - setIsEditable:, - editCellAtIndex:
- (int)numberOfColumns
See Also: - numberOfRows
- (int)numberOfRows
See Also: - numberOfColumns
- (NSRect)rectOfColumn:(int)column
See Also: - columnAtIndex:
- (float)rowHeight
cellSize
(NSCell).See Also: - setRowHeight:
- (void)scrollColumnToVisible:(int)column
See Also: - scrollToSelection
- (void)scrollToSelection
See Also: - scrollColumnToVisible:
- (void)selectCellAtIndex:(int)index
YES
. If index is outside the scope of the data source, no selection takes place.Posts a SSListViewSelectionDidChangeNotification to the default notification center if the selection does in fact change. This method doesn't check with the delegate before changing the selection. If the user is editing a cell, editing is simply forced to end and the selection is changed.
See Also: - indexOfSelectedCell
- (void)setAction:(SEL)aSelector
See Also: - setDoubleAction:, - setTarget:, - action
- (void)setAlignment:(NSTextAlignment)mode
NSLeftTextAlignment
, NSRightTextAlignment
, NSCenterTextAlignment
, NSJustifiedTextAlignment
, NSNaturalTextAlignment
(the default alignment for the text). This method sets the alignment of the cell.See Also: - alignment
- (void)setAllowsSelection:(BOOL)flag
YES
selection is allowed; if flag is NO
the user cannot select a cell. The default setting is NO
.
You can select a cell programmatically, however, even if user selection is disallowed. If flag is NO
, indexOfSelectedCell will return -1.
See Also: - allowsSelection
- (void)setDataSource:(id)aSource
See Also: - dataSource
- (void)setDelegate:(id)anObject
See Also: - delegate
- (void)setDoubleAction:(SEL)aSelector
See Also: - setAction:, - setTarget:, - doubleAction
- (void)setDrawsGrid:(BOOL)flag
YES
it does; if flag is NO
it doesn't. The default is NO
.
If flag is YES
, the width of intercellSpacing is set to 1, unless it is already non-zero.
See Also: - setGridColor:, - drawsGrid
- (void)setFormatter:(NSFormatter *)newFormatter
getObjectValue:forString:errorDescription:
. newFormatter is attached to the cell, and to the editing cell, if isEditable returns YES
.See Also: - formatter
- (void)setGridColor:(NSColor *)color
See Also: - setDrawsGrid:, - gridColor
- (void)setIntercellSpacing:(NSSize)aSize
See Also: - intercellSpacing
- (void)setIsEditable:(BOOL)flag
YES
it is editable; if flag is NO
it isn't editable. The default is NO
.
If flag is YES
, an NSTextFieldCell is created for the windows field editor, if required; if flag is NO
, the editing cell is released, if applicable.
See Also: - isEditable, - editCellAtIndex:
- (void)setRowHeight:(float)height
See Also: - rowHeight
- (void)setTarget:(id)anObject
See Also: - setDoubleAction:, - setAction:, - target
- (id)target
See Also: - doubleAction, - action, - setTarget:
- (void)textDidChange:(NSNotification *)aNotification
- (void)textDidEndEditing:(NSNotification *)aNotification
See Also: - textShouldEndEditing:
- (BOOL)textShouldEndEditing:(NSText *)textObject
getObjectValue:forString:errorDescription:
and the delegate method listView:didFailToFormatString:errorDescription:. Finally, it queries the delegate using listView:textShouldEndEditing:, returning the delegate's response if it responds to that method. If it doesn't, it returns YES if the cell's new value is valid and NO if it isn't.See Also: - textDidEndEditing:
- Informal protocol:
- NSObject (SSListViewDataSource)
- (int)numberOfObjectsInListView:(SSListView *)listView
- (id)listView:(SSListView *)listView objectValueAtIndex:(int)index
- (void)listView:(SSListView *)listView setObjectValue:(id)anObject atIndex:(int)index
- Informal protocol:
- NSObject (SSListViewDelegate)
- (BOOL)listView:(SSListView *)listView didFailToFormatString:(NSString *)string errorDescription:(NSString *)error
YES
if string should be accepted as-is, or NO
if string should be rejected.
See Also: getObjectValue:forString:errorDescription:
(NSFormatter)
- (void)listView:(SSListView *)listView didFailToValidatePartialString:(NSString *)string errorDescription:(NSString *)error
- (BOOL)listView:(SSListView *)listView shouldEditCell:(id)aCell atIndex:(int)index
YES
to permit listView to edit the cell at index, NO
to deny permission. The delegate can implement this method to disallow editing of specific cells.- (BOOL)listView:(SSListView *)listView shouldSelectCell:(id)aCell atIndex:(int)index
YES
to permit listView to select the cell at index, NO
to deny permission. The delegate can implement this method to disallow selection of particular cells.- (BOOL)listView:(SSListView *)listView textShouldEndEditing:(NSText *)fieldEditor
YES
if the view's fieldEditor should be allowed to end its edit session, NO
otherwise.- (BOOL)listView:(SSListView *)listView textView:(NSTextView *)textView doCommandBySelector:(SEL)command
YES
if it handles the key binding, and NO
otherwise. These bindings are usually implemented as methods (command) defined in NSResponder; examples of such key bindings are arrow keys (for directional movement) and the Escape key (for name completion). By implementing this method, the delegate can override the default implementation of command and supply its own behavior.- (void)tableView:(SSListView *)listView willDisplayCell:(id)aCell atIndex:(int)index
SSListView posts the following notifications to interested observers and its delegate.
nil
.
nil
.
textDidEndEditing
message to the listview, which passes it on in this form to its delegate.) The userInfo dictionary contains the key @"NSFieldEditor"
and the value is the edited cell's field editor.
© 2003 Sork Software