Protocol

NSTableViewDelegate

A set of optional methods you implement in a table view delegate to customize the behavior of the table view.

Overview

Using a table view delegate allows you to customize a table view’s behavior without creating a table view subclass. A table view delegate provides views for table rows and columns, and supports functionality such as column reordering and resizing and row selection. To learn more about table views, see NSTableView.

Symbols

Providing Views for Rows and Columns

func tableView(NSTableView, viewFor: NSTableColumn?, row: Int)

Asks the delegate for a view to display the specified row and column.

func tableView(NSTableView, rowViewForRow: Int)

Asks the delegate for a view to display the specified row.

Notification of Row Views Being Added or Removed

func tableView(NSTableView, didAdd: NSTableRowView, forRow: Int)

Tells the delegate that a row view was added at the specified row.

func tableView(NSTableView, didRemove: NSTableRowView, forRow: Int)

Tells the delegate that a row view was removed from the table at the specified row.

Grouping Rows

func tableView(NSTableView, isGroupRow: Int)

Returns whether the specified row is a group row.

Providing Cells for Rows and Columns

func tableView(NSTableView, willDisplayCell: Any, for: NSTableColumn?, row: Int)

Tells the delegate that the table view will display the specified cell at the specified row and column.

func tableView(NSTableView, dataCellFor: NSTableColumn?, row: Int)

Asks the delegate for a custom data cell for the specified row and column.

func tableView(NSTableView, shouldShowCellExpansionFor: NSTableColumn?, row: Int)

Asks the delegate if an expansion tooltip should be displayed for a specific row and column.

func tableView(NSTableView, toolTipFor: NSCell, rect: NSRectPointer, tableColumn: NSTableColumn?, row: Int, mouseLocation: NSPoint)

Asks the delegate for a string to display in a tooltip for the specified cell in the column and row.

Editing Cells

func tableView(NSTableView, shouldEdit: NSTableColumn?, row: Int)

Asks the delegate if the cell at the specified row and column can be edited.

Setting Row and Column Size

func tableView(NSTableView, heightOfRow: Int)

Asks the delegate for the height of the specified row.

func tableView(NSTableView, sizeToFitWidthOfColumn: Int)

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

Selecting Rows

func selectionShouldChange(in: NSTableView)

Asks the delegate if the user is allowed to change the selection.

func tableView(NSTableView, shouldSelectRow: Int)

Asks the delegate if the table view should allow selection of the specified row.

func tableView(NSTableView, selectionIndexesForProposedSelection: IndexSet)

Asks the delegate to accept or reject the proposed selection.

func tableView(NSTableView, shouldSelect: NSTableColumn?)

Asks the delegate whether the specified table column can be selected.

func tableViewSelectionIsChanging(Notification)

Tells the delegate that the table view’s selection is in the process of changing.

func tableViewSelectionDidChange(Notification)

Tells the delegate that the table view’s selection has changed.

func tableView(NSTableView, shouldTypeSelectFor: NSEvent, withCurrentSearch: String?)

Asks the delegate to allow or deny type select for the specified event and current search string.

func tableView(NSTableView, typeSelectStringFor: NSTableColumn?, row: Int)

Asks the delegate to provide an alternative text value used for type selection for the specified row and column.

func tableView(NSTableView, nextTypeSelectMatchFromRow: Int, toRow: Int, for: String)

Asks the delegate for the row within the specified search range that matches the specified string.

Moving and Resizing Columns

func tableView(NSTableView, shouldReorderColumn: Int, toColumn: Int)

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

func tableView(NSTableView, didDrag: NSTableColumn)

Tells the delegate that the specified table column was dragged.

func tableViewColumnDidMove(Notification)

Tells the delegate that a table column was moved by user action.

func tableViewColumnDidResize(Notification)

Tells the delegate that a table column was resized.

Responding to Mouse Events

func tableView(NSTableView, didClick: NSTableColumn)

Tells the delegate that the mouse button was clicked in the specified table column, but the column was not dragged.

func tableView(NSTableView, mouseDownInHeaderOf: NSTableColumn)

Tells the delegate that the mouse button was clicked in the specified table column’s header.

func tableView(NSTableView, shouldTrackCell: NSCell, for: NSTableColumn?, row: Int)

Asks the delegate whether the specified cell should be tracked.

Enabling Table Row Actions

func tableView(NSTableView, rowActionsForRow: Int, edge: NSTableRowActionEdge)

Asks the delegate to provide an array of row actions to be attached to the specified edge of a table row and displayed when the user swipes horizontally across the row.

Relationships