Mac Developer Library

Developer

AppKit Framework Reference NSBrowserDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSBrowserDelegate

The NSBrowserDelegate protocol defines the method that a delegate of NSBrowser should implement.

  • Asks the delegate to select the cell with the given title in the specified column.

    Declaration

    Swift

    optional func browser(_ sender: NSBrowser, selectCellWithString title: String, inColumn column: Int) -> Bool

    Objective-C

    - (BOOL)browser:(NSBrowser *)sender selectCellWithString:(NSString *)title inColumn:(NSInteger)column

    Parameters

    sender

    The browser.

    title

    The title of the cell to select.

    column

    The index of the column containing the cell to select.

    Return Value

    YEStrue if the cell was successfully selected; otherwise, NOfalse.

    Discussion

    Invoked in response to the setPath: method of NSBrowser being received by sender.

    Availability

    Available in OS X v10.0 and later.

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

    See Also

    – selectedCellInColumn: (NSBrowser)

  • Asks the delegate to select the cell at the specified row and column location.

    Declaration

    Swift

    optional func browser(_ sender: NSBrowser, selectRow row: Int, inColumn column: Int) -> Bool

    Objective-C

    - (BOOL)browser:(NSBrowser *)sender selectRow:(NSInteger)row inColumn:(NSInteger)column

    Parameters

    sender

    The browser.

    row

    The index of the row containing the cell to select.

    column

    The index of the column containing the cell to select.

    Return Value

    YEStrue if the cell was selected; otherwise, NOfalse.

    Discussion

    Invoked in response to selectRow:inColumn: of NSBrowser being received by sender.

    Availability

    Available in OS X v10.0 and later.

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

    See Also

    – selectedRowInColumn: (NSBrowser)
    – selectRow:inColumn: (NSBrowser)

  • Asks the delegate for a set of indexes to select when the user changes the selection in the browser with the keyboard or mouse.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, selectionIndexesForProposedSelection proposedSelectionIndexes: NSIndexSet, inColumn column: Int) -> NSIndexSet

    Objective-C

    - (NSIndexSet *)browser:(NSBrowser *)browser selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes inColumn:(NSInteger)column

    Parameters

    browser

    The browser.

    proposedSelectionIndexes

    The set of indexes of the items in the proposed selection.

    column

    The column index of the column containing the selection.

    Return Value

    The set of indexes of the items that should be selected.

    Discussion

    This method may be called multiple times, with one new index added to the previous selection, to see whether a particular index can be selected when the user is extending the selection with the keyboard or mouse. The proposedSelectionIndexes parameter contains the entire selection, and you can return the existing selection if you do not want to change it. This method works only for item-based browsers.

    Availability

    Available in OS X v10.6 and later.

  • Notifies the delegate when the browser will scroll.

    Declaration

    Swift

    optional func browserWillScroll(_ sender: NSBrowser)

    Objective-C

    - (void)browserWillScroll:(NSBrowser *)sender

    Parameters

    sender

    The browser sending the message.

    Availability

    Available in OS X v10.0 and later.

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

  • Notifies the delegate when the browser has scrolled.

    Declaration

    Swift

    optional func browserDidScroll(_ sender: NSBrowser)

    Objective-C

    - (void)browserDidScroll:(NSBrowser *)sender

    Parameters

    sender

    The browser sending the message.

    Availability

    Available in OS X v10.0 and later.

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

  • Used to determine a column’s initial size.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, shouldSizeColumn columnIndex: Int, forUserResize forUserResize: Bool, toWidth suggestedWidth: CGFloat) -> CGFloat

    Objective-C

    - (CGFloat)browser:(NSBrowser *)browser shouldSizeColumn:(NSInteger)columnIndex forUserResize:(BOOL)forUserResize toWidth:(CGFloat)suggestedWidth

    Parameters

    browser

    The browser.

    columnIndex

    The index of the column to size.

    forUserResize

    Currently, this is always set to NOfalse.

    suggestedWidth

    The suggested width for the column.

    Return Value

    The delegate's desired initial width for a newly added column. If you want to accept the suggested width, return suggestedWidth. If you return 0 or a size too small to display the resize handle and a portion of the column, the actual size used will be larger than the size you requested.

    Discussion

    This method applies only to browsers with resize type NSBrowserNoColumnResizing or NSBrowserUserColumnResizing (see NSBrowserColumnResizingType).

    Availability

    Available in OS X v10.3 and later.

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

    See Also

    – setWidth:ofColumn: (NSBrowser)

  • Returns the ideal width for a column.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, sizeToFitWidthOfColumn columnIndex: Int) -> CGFloat

    Objective-C

    - (CGFloat)browser:(NSBrowser *)browser sizeToFitWidthOfColumn:(NSInteger)columnIndex

    Parameters

    browser

    The browser.

    columnIndex

    The index of the column to size. If -1, the result is used to resize all columns.

    Return Value

    The ideal width of the column. This method is used when performing a “right-size” operation, that is, when sizing a column to the smallest width that contains all the content without clipping or truncating.

    If columnIndex is –1, you should return a size that can be uniformly applied to all columns (that is, every column will be set to this size).

    Returning a value of -1 allows you to opt-out of providing a width for the requested column.

    Discussion

    This method applies only to browsers with resize type NSBrowserUserColumnResizing.

    It is assumed that the implementation may be expensive, so it will be called only when necessary.

    Availability

    Available in OS X v10.3 and later.

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

  • Used by clients to implement their own column width persistence.

    Declaration

    Swift

    optional func browserColumnConfigurationDidChange(_ notification: NSNotification)

    Objective-C

    - (void)browserColumnConfigurationDidChange:(NSNotification *)notification

    Parameters

    notification

    Discussion

    This method applies only to browsers with resize type NSBrowserUserColumnResizing. It is invoked when the setWidth:ofColumn: method of NSBrowser is used to change the width of any browser columns or when the user resizes any columns. If the user resizes more than one column, a single notification is posted when the user is finished resizing.

    Availability

    Available in OS X v10.3 and later.

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

    See Also

    – setWidth:ofColumn: (NSBrowser)

  • Specifies the height of the specified row in the specified column.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, heightOfRow row: Int, inColumn columnIndex: Int) -> CGFloat

    Objective-C

    - (CGFloat)browser:(NSBrowser *)browser heightOfRow:(NSInteger)row inColumn:(NSInteger)columnIndex

    Parameters

    browser

    The browser.

    row

    The index of the row.

    columnIndex

    The index of the column.

    Return Value

    The height to set for the specified row, which must be greater than 0.

    Discussion

    The values returned for this method may be cached. Therefore, you should call noteHeightOfRowsWithIndexesChanged:inColumn: to invalidate a row’s height before changing it.

    Availability

    Available in OS X v10.6 and later.

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

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, shouldShowCellExpansionForRow row: Int, column column: Int) -> Bool

    Objective-C

    - (BOOL)browser:(NSBrowser *)browser shouldShowCellExpansionForRow:(NSInteger)row column:(NSInteger)column

    Parameters

    browser

    The browser.

    row

    The index of the row requesting an expansion tooltip.

    column

    The index of the column containing the requesting row.

    Return Value

    YEStrue to allow the cell expansion tooltip; NOfalse to disallow it.

    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 YES, the full cell contents will be shown in a special floating tool tip view, otherwise the content is truncated.

    Availability

    Available in OS X v10.5 and later.

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