Mac Developer Library

Developer

AppKit Framework Reference NSOutlineViewDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSOutlineViewDelegate

The NSOutlineViewDelegate protocol defines the optional methods implemented by delegates of NSOutlineView objects.

Inheritance


Not Applicable

Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.6 and later.
  • Returns a Boolean value that indicates whether the outline view should expand a given item.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldExpandItem item: AnyObject) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    item

    The item that should expand.

    Return Value

    YEStrue to permit outlineView to expand item, NOfalse to deny permission.

    Discussion

    The delegate can implement this method to disallow expanding of specific items.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns a Boolean value that indicates whether the outline view should collapse a given item.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldCollapseItem item: AnyObject) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldCollapseItem:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    item

    The item that should collapse.

    Return Value

    YEStrue to permit outlineView to collapse item, NOfalse to deny permission.

    Discussion

    The delegate can implement this method to disallow collapsing of specific items. For example, if the first row of your outline view should not be collapsed, your delegate method could contain this line of code:

    • return [outlineView rowForItem:item]!=0;

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns the string that is used for type selection for a given column and item.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, typeSelectStringForTableColumn tableColumn: NSTableColumn?, item item: AnyObject) -> String?

    Objective-C

    - (NSString *)outlineView:(NSOutlineView *)outlineView typeSelectStringForTableColumn:(NSTableColumn *)tableColumn item:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    tableColumn

    A table column in the outline view.

    item

    An item in the outline view.

    Return Value

    The string that is used for type selection. You may want to change what is searched for based on what is displayed, or simply return nil for that row and/or column to not be searched

    Discussion

    Implement this method if you want to control the string that is used for type selection. You may want to change what is searched for based on what is displayed, or simply return nil to specify that the given row and/or column should not be searched. By default, all cells with text in them are searched.

    The default value when this delegate method is not implemented is:

    • [[outlineView preparedCellAtColumn:tableColumn row:[outlineView rowForItem:item]] stringValue]

    and you can return this value from the delegate method if you wish.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns the first item that matches the searchString from within the range of startItem to endItem

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, nextTypeSelectMatchFromItem startItem: AnyObject, toItem endItem: AnyObject, forString searchString: String) -> AnyObject?

    Objective-C

    - (id)outlineView:(NSOutlineView *)outlineView nextTypeSelectMatchFromItem:(id)startItem toItem:(id)endItem forString:(NSString *)searchString

    Parameters

    outlineView

    The outline view that sent the message.

    startItem

    The first item to search.

    endItem

    The item before which to stop searching. It is possible for endItem to be less than startItem if the search will wrap.

    searchString

    The string for which to search.

    Return Value

    The first item—from within the range of startItem to endItem—that matches the searchString, or nil if there is no match.

    Discussion

    Implement this method if you want to control how type selection works. You should include startItem as a possible match, but do not include endItem.

    It is not necessary to implement this method in order to support type select.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns a Boolean value that indicates whether type select should proceed for a given event and search string.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldTypeSelectForEvent event: NSEvent, withCurrentSearchString searchString: String?) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldTypeSelectForEvent:(NSEvent *)event withCurrentSearchString:(NSString *)searchString

    Parameters

    outlineView

    The outline view that sent the message.

    event

    The event that caused the message to be sent.

    searchString

    The string for which searching is to proceed. The search string is nil if no type select has begun.

    Return Value

    YEStrue if type select should proceed, otherwise NOfalse.

    Discussion

    Generally, this method will be called from keyDown: and the event will be a key event.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • When the cursor pauses over a given cell, the value returned from this method is displayed in a tooltip.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, toolTipForCell cell: NSCell, rect rect: NSRectPointer, tableColumn tc: NSTableColumn?, item item: AnyObject, mouseLocation mouseLocation: NSPoint) -> String

    Objective-C

    - (NSString *)outlineView:(NSOutlineView *)outlineView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc item:(id)item mouseLocation:(NSPoint)mouseLocation

    Parameters

    outlineView

    The outline view that sent the message.

    cell

    The cell for which to generate a tooltip.

    rect

    The proposed active area of the tooltip. To control the default active area, you can modify the rect parameter. By default, rect is computed as [cell drawingRectForBounds:cellFrame].

    tc

    The table column that contains cell.

    item

    The item for which to display a tooltip.

    mouseLocation

    The current mouse location in view coordinates.

    Return Value

    If you don’t want a tooltip at that location, return nil or the empty string.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns a Boolean value that indicates whether the outline view should select a given table column.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldSelectTableColumn tableColumn: NSTableColumn?) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectTableColumn:(NSTableColumn *)tableColumn

    Parameters

    outlineView

    The outline view that sent the message.

    tableColumn

    The table column.

    Return Value

    YEStrue to permit outlineView to select tableColumn, NOfalse to deny permission.

    Discussion

    The delegate can implement this method to disallow selection of specific columns.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns a Boolean value that indicates whether the outline view should select a given item.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldSelectItem item: AnyObject) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    item

    The item.

    Return Value

    YEStrue to permit outlineView to select item, NOfalse to deny permission.

    Discussion

    You implement this method to disallow selection of particular items.

    For better performance and finer grain control over the selection, use outlineView:dataCellForTableColumn:item:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Invoked to allow the delegate to modify the proposed selection.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, selectionIndexesForProposedSelection proposedSelectionIndexes: NSIndexSet) -> NSIndexSet

    Objective-C

    - (NSIndexSet *)outlineView:(NSOutlineView *)outlineView selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes

    Parameters

    outlineView

    The outline view that sent the message.

    proposedSelectionIndexes

    An index set containing the indexes of the proposed selection.

    Return Value

    An NSIndexSet instance containing the indexes of the new selection. Return proposedSelectionIndexes if the proposed selection is acceptable, or the value of the table view’s existing selection to avoid changing the selection.

    Discussion

    This method may be called multiple times with one new index added to the existing selection to find out if a particular index can be selected when the user is extending the selection with the keyboard or mouse.

    Implementation of this method is optional. If implemented, this method will be called instead of outlineView:willDisplayOutlineCell:forTableColumn:item:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns a Boolean value that indicates whether the outline view should change its selection.

    Declaration

    Swift

    optional func selectionShouldChangeInOutlineView(_ outlineView: NSOutlineView) -> Bool

    Objective-C

    - (BOOL)selectionShouldChangeInOutlineView:(NSOutlineView *)outlineView

    Parameters

    outlineView

    The outline view that sent the message.

    Return Value

    YEStrue to permit outlineView to change its selection (typically a row being edited), NOfalse to deny permission.

    Discussion

    For example, if the user is editing a cell and enters an improper value, the delegate can prevent the user from selecting or editing any other cells until a proper value has been entered into the original cell. The delegate can implement this method for complex validation of edited rows based on the values of any of their cells.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Invoked when notification is posted—that is, whenever the outline view’s selection changes.

    Declaration

    Swift

    optional func outlineViewSelectionIsChanging(_ notification: NSNotification)

    Objective-C

    - (void)outlineViewSelectionIsChanging:(NSNotification *)notification

    Parameters

    notification

    The posted notification.

    Discussion

    This method is invoked as a result of posting an NSOutlineViewSelectionIsChangingNotification.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.7.

  • Invoked when the selection did change notification is posted—that is, immediately after the outline view’s selection has changed.

    Declaration

    Swift

    optional func outlineViewSelectionDidChange(_ notification: NSNotification)

    Objective-C

    - (void)outlineViewSelectionDidChange:(NSNotification *)notification

    Parameters

    notification

    The posted notification.

    Discussion

    This method is invoked as a result of posting an NSOutlineViewSelectionDidChangeNotification.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.7.

  • Informs the delegate that the cell specified by the column and item will be displayed.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, willDisplayCell cell: AnyObject, forTableColumn tableColumn: NSTableColumn?, item item: AnyObject)

    Objective-C

    - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    cell

    The cell.

    tableColumn

    The table column.

    item

    The item.

    Discussion

    The delegate can implement this method to modify cell to provide further setup for the cell in tableColumn and item. It is not safe to do drawing inside this method—you should only set up state for cell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Informs the delegate that an outline view is about to display a cell used to draw the expansion symbol.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, willDisplayOutlineCell cell: AnyObject, forTableColumn tableColumn: NSTableColumn?, item item: AnyObject)

    Objective-C

    - (void)outlineView:(NSOutlineView *)outlineView willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    cell

    The cell.

    tableColumn

    The table column.

    item

    The item.

    Discussion

    Informs the delegate that outlineView is about to display cell—an expandable cell (a cell that has the expansion symbol)—for the column and item specified by tableColumn and item. The delegate can modify cell to alter its display attributes.

    This method is not invoked when outlineView is about to display a non-expandable cell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns the cell to use in a given column for a given item.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, dataCellForTableColumn tableColumn: NSTableColumn?, item item: AnyObject) -> NSCell?

    Objective-C

    - (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    tableColumn

    The table column for which the cell is required. This value may be nil.

    item

    The item for which the cell is required.

    Return Value

    The cell to use in column tableColumn for item item, or nil. The cell must properly implement copyWithZone: (since it may be copied by by the outline view).

    Discussion

    You can return a different data cell for any particular combination of table column and item, or a cell that will be used for the entire row (a full-width cell). If tableColumn is non-nil, you should return a cell. Typically, you should default to returning the result from [tableColumn dataCellForRow:row].

    When each row (identified by the item) is being drawn, this method is first called with a nil value for tableColumn. At this time, you can return a cell that is used to draw the entire row, acting like a group. If you do return a cell for the nil table column, your implementations of the other corresponding data source and delegate methods must be prepared to be invoked with a nil value for tableColumn. If do not return a cell for the nil table column, the method is called once for each column in the outline view, as usual.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns a whether the specified item should display the outline cell (the disclosure triangle).

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldShowOutlineCellForItem item: AnyObject) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    item

    An item in the outline view.

    Return Value

    YEStrue if the outline cell should be displayed, otherwise NOfalse.

    Discussion

    Returning NOfalse causes frameOfOutlineCellAtRow: to return NSZeroRect, hiding the cell. In addition, the row will not be collapsible by keyboard shortcuts.

    This method is called only for expandable rows.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Invoked to allow the delegate to control cell expansion for a specific column and item.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldShowCellExpansionForTableColumn tableColumn: NSTableColumn?, item item: AnyObject) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowCellExpansionForTableColumn:(NSTableColumn *)tableColumn item:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    tableColumn

    A table column in the outline view.

    item

    An item in the outline view.

    Return Value

    YEStrue to allow an expansion tooltip to appear in the column tableColumn for item item, otherwise NOfalse.

    Discussion

    Cell expansion can occur when the mouse hovers over the specified cell and the cell contents are unable to be fully displayed within the cell. If this method returns YEStrue, the full cell contents will be shown in a special floating tool tip view, otherwise the content is truncated.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Sent to the delegate to allow or prohibit the specified column to be dragged to a new location.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldReorderColumn columnIndex: Int, toColumn newColumnIndex: Int) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldReorderColumn:(NSInteger)columnIndex toColumn:(NSInteger)newColumnIndex

    Parameters

    outlineView

    The outline view that sent the message.

    columnIndex

    The index of the column being dragged.

    newColumnIndex

    The proposed target index of the column.

    Return Value

    YEStrue if the column reordering should be allowed, otherwise NOfalse.

    Discussion

    When a column is initially dragged by the user, the delegate is first called with a newColumnIndex value of -1. Returning NOfalse will disallow that column from being reordered at all. Returning YEStrue allows it to be reordered, and the delegate will be called again when the column reaches a new location.

    The actual NSTableColumn instance can be retrieved from the tableColumns array.

    If this method is not implemented, all columns are considered reorderable.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Invoked whenever the user moves a column in the outline view.

    Declaration

    Swift

    optional func outlineViewColumnDidMove(_ notification: NSNotification)

    Objective-C

    - (void)outlineViewColumnDidMove:(NSNotification *)notification

    Parameters

    notification

    The posted notification.

    Discussion

    This method is invoked as a result of posting an NSOutlineViewColumnDidMoveNotification.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.7.

  • Invoked whenever the user resizes a column in the outline view.

    Declaration

    Swift

    optional func outlineViewColumnDidResize(_ notification: NSNotification)

    Objective-C

    - (void)outlineViewColumnDidResize:(NSNotification *)notification

    Parameters

    notification

    The posted notification.

    Discussion

    This method is invoked as a result of posting an NSOutlineViewColumnDidResizeNotification.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.7.

  • Invoked when notification is posted—that is, whenever the user is about to expand an item in the outline view.

    Declaration

    Swift

    optional func outlineViewItemWillExpand(_ notification: NSNotification)

    Objective-C

    - (void)outlineViewItemWillExpand:(NSNotification *)notification

    Parameters

    notification

    The posted notification.

    Discussion

    This method is invoked as a result of posting an NSOutlineViewItemWillExpandNotification.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.7.

  • Invoked when notification is posted—that is, whenever the user expands an item in the outline view.

    Declaration

    Swift

    optional func outlineViewItemDidExpand(_ notification: NSNotification)

    Objective-C

    - (void)outlineViewItemDidExpand:(NSNotification *)notification

    Parameters

    notification

    The posted notification.

    Discussion

    This method is invoked as a result of posting an NSOutlineViewItemDidExpandNotification.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.7.

  • Invoked when notification is posted—that is, whenever the user is about to collapse an item in the outline view.

    Declaration

    Swift

    optional func outlineViewItemWillCollapse(_ notification: NSNotification)

    Objective-C

    - (void)outlineViewItemWillCollapse:(NSNotification *)notification

    Parameters

    notification

    The posted notification.

    Discussion

    This method is invoked as a result of posting an NSOutlineViewItemWillCollapseNotification.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.7.

  • Invoked when the did collapse notification is posted—that is, whenever the user collapses an item in the outline view.

    Declaration

    Swift

    optional func outlineViewItemDidCollapse(_ notification: NSNotification)

    Objective-C

    - (void)outlineViewItemDidCollapse:(NSNotification *)notification

    Parameters

    notification

    The posted notification.

    Discussion

    This method is invoked as a result of posting an NSOutlineViewItemDidCollapseNotification.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.7.

  • Returns a Boolean value that indicates whether the outline view should allow editing of a given item in a given table column.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldEditTableColumn tableColumn: NSTableColumn?, item item: AnyObject) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    tableColumn

    The table column.

    item

    The item.

    Return Value

    YEStrue to permit outlineView to edit the cell specified by tableColumn and item, NOfalse to deny permission.

    If this method returns YEStrue, the cell may still not be editable—for example, if you have set up a custom NSTextFieldCell as a data cell, it must return YEStrue for isEditable to allow editing.

    Discussion

    The delegate can implement this method to disallow editing of specific cells.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

    See Also

    outlineView:setObjectValue:forTableColumn:byItem: (NSOutlineViewDatasource Protocol)

  • Sent to the delegate whenever the mouse button is clicked in outlineView while the cursor is in a column header tableColumn.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, mouseDownInHeaderOfTableColumn tableColumn: NSTableColumn)

    Objective-C

    - (void)outlineView:(NSOutlineView *)outlineView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn

    Parameters

    outlineView

    The outline view that sent the message.

    tableColumn

    The table column.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Sent at the time the mouse button subsequently goes up in outlineView and tableColumn has been “clicked” without having been dragged anywhere.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, didClickTableColumn tableColumn: NSTableColumn)

    Objective-C

    - (void)outlineView:(NSOutlineView *)outlineView didClickTableColumn:(NSTableColumn *)tableColumn

    Parameters

    outlineView

    The outline view that sent the message.

    tableColumn

    The table column.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Sent at the time the mouse button goes up in outlineView and tableColumn has been dragged during the time the mouse button was down.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, didDragTableColumn tableColumn: NSTableColumn)

    Objective-C

    - (void)outlineView:(NSOutlineView *)outlineView didDragTableColumn:(NSTableColumn *)tableColumn

    Parameters

    outlineView

    The outline view that sent the message.

    tableColumn

    The table column.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns the height in points of the row containing item.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, heightOfRowByItem item: AnyObject) -> CGFloat

    Objective-C

    - (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    item

    The row item.

    Return Value

    The height of the row.

    Discussion

    Values returned by this method should not include intercell spacing and must be greater than 0.

    Implement this method to support an outline view with varying row heights.

    For large tables in particular, you should make sure that this method is efficient. NSOutlineView may cache the values this method returns, so if you would like to change a row's height make sure to invalidate the row height by calling noteHeightOfRowsWithIndexesChanged:. NSOutlineView automatically invalidates its entire row height cache in reloadData and noteNumberOfRowsChanged.

    If you call viewAtColumn:row:makeIfNecessary: or rowViewAtRow:makeIfNecessary: within your implementation of this method, an exception is thrown.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Invoked to allow the delegate to provide custom sizing behavior when a column’s resize divider is double clicked.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, sizeToFitWidthOfColumn column: Int) -> CGFloat

    Objective-C

    - (CGFloat)outlineView:(NSOutlineView *)outlineView sizeToFitWidthOfColumn:(NSInteger)column

    Parameters

    outlineView

    The outline view that sent the message.

    column

    The index of the column.

    Return Value

    The width of the specified column.

    Discussion

    By default, NSOutlineView iterates every row in the table, accesses a cell via preparedCellAtColumn:row:, and requests the cellSize to find the appropriate largest width to use.

    For accurate results and performance, it is recommended that this method is implemented when using large tables. By default, large tables use a monte carlo simulation instead of iterating every row.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns a Boolean value that indicates whether a given cell should be tracked.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, shouldTrackCell cell: NSCell, forTableColumn tableColumn: NSTableColumn?, item item: AnyObject) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    cell

    The cell used to display item item in column tableColumn

    tableColumn

    A table column in the outline view.

    item

    An item in the outline view.

    Return Value

    YEStrue if the cell should be tracked for the item item in column tableColumn, otherwise NOfalse.

    Discussion

    Normally, only selectable or selected cells can be tracked. If you implement this method, cells which are not selectable or selected can be tracked (and vice-versa). For example, this allows you to have a button cell in a table which does not change the selection, but can still be clicked on and tracked.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Returns a Boolean that indicates whether a given row should be drawn in the “group row” style.

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, isGroupItem item: AnyObject) -> Bool

    Objective-C

    - (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    item

    An item in the outline view.

    Return Value

    YEStrue to indicate a particular row should have the "group row" style drawn for that row, otherwise NOfalse.

    Discussion

    If the cell in that row is an instance of NSTextFieldCell and contains only a string value, the “group row” style attributes are automatically applied for that cell.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Implemented to know when a new row view is added to the table. (required)

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, didAddRowView rowView: NSTableRowView, forRow row: Int)

    Objective-C

    - (void)outlineView:(NSOutlineView *)outlineView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row

    Parameters

    outlineView

    The outline view that sent the message.

    rowView

    The new row view.

    row

    The row to which the view was added.

    Discussion

    This delegate method is for NSView-based outline views. At this point, you can choose to add in extra views or modify any properties on rowView.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • Implemented to know when a row view is removed from the table (required)

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, didRemoveRowView rowView: NSTableRowView, forRow row: Int)

    Objective-C

    - (void)outlineView:(NSOutlineView *)outlineView didRemoveRowView:(NSTableRowView *)rowView forRow:(NSInteger)row

    Parameters

    outlineView

    The outline view that sent the message.

    rowView

    The row view that was removed.

    row

    The number of the row that was removed due to being moved offscreen, or -1 if the row was removed from the table so it is no longer valid.

    Discussion

    The removed rowView may be reused by the table, so any additionally inserted views should be removed at this point.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • implement this method to return a custom NSTableRowView for a particular item. (required)

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, rowViewForItem item: AnyObject) -> NSTableRowView?

    Objective-C

    - (NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    item

    The item displayed by the returned table row view.

    Return Value

    An instance or subclass of NSTableRowView. If nil is returned, a NSTableRowView instance is created and used.

    Discussion

    This method, if implemented, is only invoked for NSView-based outline views.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • Implemented to return the view used to display the specified item and column. (required)

    Declaration

    Swift

    optional func outlineView(_ outlineView: NSOutlineView, viewForTableColumn tableColumn: NSTableColumn?, item item: AnyObject) -> NSView?

    Objective-C

    - (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item

    Parameters

    outlineView

    The outline view that sent the message.

    tableColumn

    The table column, or nil if the row is a group row.

    item

    The item displayed by the returned view.

    Return Value

    The view to display the specified column and row. Returning nil is acceptable, in which case a view is not shown at that location.

    Discussion

    This method is required if you wish to use NSView objects instead of NSCell objects for the cells within an outline view. Cells and views cannot be mixed within the same outline view.

    It is recommended that the implementation of this method first call the NSTableView method makeViewWithIdentifier:owner: passing, respectively, the tableColumn parameter’s identifier and self as the owner to attempt to reuse a view that is no longer visible. The frame of the view returned by this method is not important, and is automatically set by the outline view.

    The view's properties should be properly set up before returning the result.

    When using Cocoa bindings, this method is optional if at least one identifier has been associated with the table view at design time. If this method is not implemented, the outline view automatically calls makeViewWithIdentifier:owner: with the tableColumn parameter’s identifier and the outline view’s delegate as parameters, to attempt to reuse a previous view or automatically unarchive a prototype associated with the table view.

    The autoresizingMask of the returned view is automatically set to NSViewHeightSizable to resize properly on row height changes.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.