Mac Developer Library

Developer

AppKit Framework Reference NSBrowserDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSBrowserDelegate

Inheritance


Not Applicable

Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.6 and later.

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

  • Returns whether the contents of the specified column are valid.

    Declaration

    Swift

    optional func browser(_ sender: NSBrowser, isColumnValid column: Int) -> Bool

    Objective-C

    - (BOOL)browser:(NSBrowser *)sender isColumnValid:(NSInteger)column

    Parameters

    sender

    The browser containing the column to validate.

    column

    The index of the column to validate.

    Return Value

    YEStrue if the column’s contents are valid; otherwise, NOfalse. If NOfalse is returned, sender reloads the column.

    Discussion

    This method is invoked in response to the validateVisibleColumnsmethod of NSBrowser being sent to sender.

    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 number of rows of data in the specified column.

    Declaration

    Swift

    optional func browser(_ sender: NSBrowser, numberOfRowsInColumn column: Int) -> Int

    Objective-C

    - (NSInteger)browser:(NSBrowser *)sender numberOfRowsInColumn:(NSInteger)column

    Parameters

    sender

    The browser.

    column

    The index of the column.

    Return Value

    The number of rows of data.

    Discussion

    Either this method or browser:createRowsForColumn:inMatrix: must be implemented, but not both.

    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.

  • Asks the delegate for the number of children the given item has.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, numberOfChildrenOfItem item: AnyObject?) -> Int

    Objective-C

    - (NSInteger)browser:(NSBrowser *)browser numberOfChildrenOfItem:(id)item

    Parameters

    browser

    The browser.

    item

    The item that has some number of children.

    Return Value

    The number of children.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Asks the delegate for the title to display above the specified column.

    Declaration

    Swift

    optional func browser(_ sender: NSBrowser, titleOfColumn column: Int) -> String?

    Objective-C

    - (NSString *)browser:(NSBrowser *)sender titleOfColumn:(NSInteger)column

    Parameters

    sender

    The browser.

    column

    The index the column to be titled.

    Return Value

    The title of the specified column.

    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.

  • 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.

    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

    – 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.

    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

    – 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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Asks the delegate to return the child of the specified item at the specified index.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, child index: Int, ofItem item: AnyObject?) -> AnyObject

    Objective-C

    - (id)browser:(NSBrowser *)browser child:(NSInteger)index ofItem:(id)item

    Parameters

    browser

    The browser.

    index

    The child’s index.

    item

    The item containing the child.

    Return Value

    The child at the specified index.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Asks the delegate whether the specified item is a leaf item (an item that cannot be expanded).

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, isLeafItem item: AnyObject?) -> Bool

    Objective-C

    - (BOOL)browser:(NSBrowser *)browser isLeafItem:(id)item

    Parameters

    browser

    The browser.

    item

    The item to be checked.

    Return Value

    YEStrue if the specified item is a leaf item; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Asks the delegate whether the browser may start an editing session for the specified item.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, shouldEditItem item: AnyObject?) -> Bool

    Objective-C

    - (BOOL)browser:(NSBrowser *)browser shouldEditItem:(id)item

    Parameters

    browser

    The browser.

    item

    The item to edit.

    Return Value

    YEStrue to allow the editing session to begin; NOfalse to disallow it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns the object that the specified item uses to draw its contents.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, objectValueForItem item: AnyObject?) -> AnyObject?

    Objective-C

    - (id)browser:(NSBrowser *)browser objectValueForItem:(id)item

    Parameters

    browser

    The browser.

    item

    The item in question.

    Return Value

    The item’s object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Sets the object that the specified item uses to draw its contents to the specified object.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, setObjectValue object: AnyObject?, forItem item: AnyObject?)

    Objective-C

    - (void)browser:(NSBrowser *)browser setObjectValue:(id)object forItem:(id)item

    Parameters

    browser

    The browser.

    object

    The object to set.

    item

    The item whose object is set.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Asks the delegate to return the root item of the browser.

    Declaration

    Swift

    optional func rootItemForBrowser(_ browser: NSBrowser) -> AnyObject?

    Objective-C

    - (id)rootItemForBrowser:(NSBrowser *)browser

    Parameters

    browser

    The browser.

    Return Value

    The browser’s root item.

    Discussion

    By default, nil identifies the root item. This method can specify a different root item. To reload the previously set root item, call loadColumnZero, and rootItemForBrowser: will be called again.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Asks the delegate for a controller that provides a preview column for the specified leaf item.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, previewViewControllerForLeafItem item: AnyObject) -> NSViewController?

    Objective-C

    - (NSViewController *)browser:(NSBrowser *)browser previewViewControllerForLeafItem:(id)item

    Parameters

    browser

    The browser.

    item

    The leaf item.

    Return Value

    A view controller that provides a preview column, or nil to suppress the preview column.

    Discussion

    The returned controller’s represented object is set to the specified leaf item. This method is called only if the delegate implements the item data source methods.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Asks the delegate for a controller that provides a header view for the specified column item.

    Declaration

    Swift

    optional func browser(_ browser: NSBrowser, headerViewControllerForItem item: AnyObject?) -> NSViewController?

    Objective-C

    - (NSViewController *)browser:(NSBrowser *)browser headerViewControllerForItem:(id)item

    Parameters

    browser

    The browser.

    item

    The column item.

    Return Value

    A view controller that provides a header view, or nil to omit the header view.

    Discussion

    The returned controller’s represented object will be set to the column item. This method is called only if the delegate implements the item data source methods.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    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.

    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.

  • 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.

    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.

  • 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).

    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.

    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.

    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.

  • 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.

    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.

    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.

    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 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.

    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.