NSBrowser Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.0 and later.
Companion guide
Declared in
NSBrowser.h
Related sample code

Overview

This class provides a user interface for displaying and selecting items from a list of data or from hierarchically organized lists of data such as directory paths. Instances of this class are known as browsers. When working with a hierarchy of data, the levels are displayed in columns, which are indexed from left to right.

This class uses the NSBrowserCell class to implement its user interface.

Browsers have the following components:

To the user, browsers display data in columns and rows within each column. These components are arranged in the following component hierarchy:

Browser
|---Columns [1..*]
    |---Scroll view
       |---Matrix
           |---Rows [0..*]

Tasks

Configuring Browsers

Getting Browser Information

Managing Component Types

Managing Selection Behavior

Managing Selection

Accessing Components

Managing the Path

Managing Columns

Accessing Column Titles

Updating Browsers

Scrolling

Dragging

Getting Column Frames

Getting Row Frames

Managing Actions

Handling Mouse-Click Events

Sizing

Class Methods

cellClass

Returns the NSBrowserCell class.

+ (Class)cellClass
Return Value

Always returns the NSBrowserCell class (even if the developer has sent a setCellClass: message to a particular instance).

Discussion

This method is used by NSControl during initialization and is not meant to be used by applications.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

removeSavedColumnsWithAutosaveName:

Removes the column configuration data stored under the given name from the application’s user defaults.

+ (void)removeSavedColumnsWithAutosaveName:(NSString *)name
Parameters
name

The name of the column configuration data to remove.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

Instance Methods

addColumn

Adds a column to the right of the last column.

- (void)addColumn
Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

allowsBranchSelection

Indicates whether the user can select branch items.

- (BOOL)allowsBranchSelection
Return Value

YES if the user can select branch items when multiple selection is enabled; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

allowsEmptySelection

Indicates whether there can be nothing selected.

- (BOOL)allowsEmptySelection
Return Value

YES if the browser allows the selection to be empty; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

allowsMultipleSelection

Indicates whether the user can select multiple items.

- (BOOL)allowsMultipleSelection
Return Value

YES if the browser allows the user to select multiple items at once; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

allowsTypeSelect

Indicates whether the browser allows keystroke-based selection (type select).

- (BOOL)allowsTypeSelect
Return Value

YES (default) when the browser allows keystroke-based selection; otherwise, NO.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSBrowser.h

autohidesScroller

Returns whether the browser automatically hides its scroller.

- (BOOL)autohidesScroller
Return Value

YES if the scroller is automatically hidden; otherwise, NO.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

backgroundColor

Provides the browser’s background color.

- (NSColor *)backgroundColor
Return Value

The browser’s background color.

Discussion

The default value is [NSColor whiteColor]

Availability
  • Available in OS X v10.5 and later.
Declared In
NSBrowser.h

canDragRowsWithIndexes:inColumn:withEvent:

Indicates whether the browser can attempt to initiate a drag of the given rows for the given event.

- (BOOL)canDragRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)columnIndex withEvent:(NSEvent *)dragEvent
Parameters
rowIndexes

Rows the user is dragging

columnIndex

Column containing the rows the user is dragging.

dragEvent

Mouse-drag event.

Return Value

YES when rowIndexes identifies at least one row and all the identified rows are enabled; otherwise, NO.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSBrowser.h

cellPrototype

Returns the browser’s prototype NSCell.

- (id)cellPrototype
Return Value

The prototype NSCell. The prototype NSCell instance is copied to display items in the matrices of the browser.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

clickedColumn

Returns the column number of the cell that the user clicked to display a context menu.

- (NSInteger)clickedColumn
Return Value

The column number of the clicked cell, or -1 if no context menu is active.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

clickedRow

Returns the row number of the cell that the user clicked to display a context menu.

- (NSInteger)clickedRow
Return Value

The row number of the clicked cell, or -1 if no context menu is active.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

columnContentWidthForColumnWidth:

Returns the content width for a given column width.

- (CGFloat)columnContentWidthForColumnWidth:(CGFloat)columnWidth
Parameters
columnWidth

The width of the column. This width is the entire scrolling text view.

Return Value

The width of the content for the column. This is the width of the matrix in the column.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

columnOfMatrix:

Returns the column number in which the given matrix is located.

- (NSInteger)columnOfMatrix:(NSMatrix *)matrix
Parameters
matrix

The matrix for which to return the column number.

Return Value

The index of the column in which the specified matrix appears.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

columnResizingType

Returns the browser’s column resizing type.

- (NSBrowserColumnResizingType)columnResizingType
Return Value

A constant indicating the column resizing type. Possible return values are described in “NSBrowserColumnResizingType”. The default is NSBrowserAutoColumnResizing

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

columnsAutosaveName

Returns the name used to automatically save the browser’s column configuration.

- (NSString *)columnsAutosaveName
Return Value

The name used to save the column configuration.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

columnWidthForColumnContentWidth:

Returns the column width for the width of the given column’s content.

- (CGFloat)columnWidthForColumnContentWidth:(CGFloat)columnContentWidth
Parameters
columnContentWidth

The width of the column's content (the width of the the matrix in the column).

Return Value

The width of the column (the width of the entire scrolling text view).

Discussion

For example, to guarantee that 16 pixels of your browser cell are always visible, call:

[browser setMinColumnWidth: [browser columnWidthForColumnContentWidth:16]]
Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

defaultColumnWidth

Returns the default column width of the browser’s columns.

- (CGFloat)defaultColumnWidth
Return Value

The default column width.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

delegate

Returns the browser’s delegate.

- (id <NSBrowserDelegate>)delegate
Return Value

The browser's delegate.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

doClick:

Responds to (single) mouse clicks in a column of the browser.

- (void)doClick:(id)sender
Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

doDoubleClick:

Responds to double clicks in a column of the browser.

- (void)doDoubleClick:(id)sender
Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

doubleAction

Returns the browser’s double-click action method.

- (SEL)doubleAction
Return Value

The action method invoked when the user double-clicks on the browser.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

draggingImageForRowsWithIndexes:inColumn:withEvent:offset:

Provides an image to represent dragged rows during a drag operation on the browser.

- (NSImage *)draggingImageForRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)columnIndex withEvent:(NSEvent *)dragEvent offset:(NSPointPointer)dragImageOffset
Parameters
rowIndexes

Rows the user is dragging.

columnIndex

Column with the rows the user is dragging.

dragEvent

Mouse drag event.

dragImageOffset

Offset for the returned image:

Return Value

Image representing the visible cells identified by rowIndexes.

Availability
  • Available in OS X v10.5 and later.
Related Sample Code
Declared In
NSBrowser.h

draggingSourceOperationMaskForLocal:

Indicates the types of dragging operations the source object allows on the dragged image’s data.

- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)localDestination
Parameters
localDestination

Indicates the location of the dragging operation’s destination object: YES for this application, NO for another application.

Return Value

Discussion

Implementation of the NSDraggingSource method draggingSourceOperationMaskForLocal:.

drawTitleOfColumn:inRect:

Draws the title for the specified column within the given rectangle.

- (void)drawTitleOfColumn:(NSInteger)column inRect:(NSRect)aRect
Parameters
column

The index of the column for which to draw the title.

aRect

The rectangle within which to draw the title.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

editItemAtIndexPath:withEvent:select:

Begins editing the item at the specified path.

- (void)editItemAtIndexPath:(NSIndexPath *)indexPath withEvent:(NSEvent *)theEvent select:(BOOL)select
Parameters
indexPath

The path of the item.

theEvent

The event to use when beginning the edit.

select

If YES, the cells contents will be selected; if NO, they will not be selected.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

firstVisibleColumn

Returns the index of the first visible column.

- (NSInteger)firstVisibleColumn
Return Value

The index of the first visible column.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

frameOfColumn:

Returns the rectangle containing the given column.

- (NSRect)frameOfColumn:(NSInteger)column
Parameters
column

The index of the column for which to retrieve the frame.

Return Value

The rectangle containing the specified column.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

frameOfInsideOfColumn:

Returns the rectangle containing the specified column, not including borders.

- (NSRect)frameOfInsideOfColumn:(NSInteger)column
Parameters
column

The index of the column for which to retrieve the inside frame.

Return Value

The rectangle containing the column, not including the column borders.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

frameOfRow:inColumn:

Returns the frame of the cell at the specified location, including the expandable arrow.

- (NSRect)frameOfRow:(NSInteger)row inColumn:(NSInteger)column
Parameters
row

The row of the cell.

column

The column of the cell.

Return Value

The frame of the cell, in the NSBrowser coordinate space.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

getRow:column:forPoint:

Gets the row and column coordinates for the specified point, if a cell exists at that point.

- (BOOL)getRow:(NSInteger *)row column:(NSInteger *)column forPoint:(NSPoint)point
Parameters
row

On output, the row number of the cell at the specified point, or -1 if there is no cell at the point.

column

On output, he column number of the cell at the specified point, or -1 if there is no cell at the point.

point

The point to test.

Return Value

YES if a cell exists at the specified point; otherwise, NO.

Discussion

If a row does not exist at point, then -1 is set for the row. If a column does not exist at point, then -1 is set for the column.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

hasHorizontalScroller

Indicates whether the browser has a horizontal scroller.

- (BOOL)hasHorizontalScroller
Return Value

YES if the browser uses an NSScroller object to scroll horizontally; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

indexPathForColumn:

Returns the index path of the item whose children are displayed in the given column.

- (NSIndexPath *)indexPathForColumn:(NSInteger)column
Parameters
column

The column to find the index path for.

Return Value

The index path of the column.

Discussion

This method can only be used if the delegate implements the item data source methods.

Availability
  • Available in OS X v10.6 and later.
Related Sample Code
Declared In
NSBrowser.h

isLeafItem:

Returns whether the specified item is a leaf item.

- (BOOL)isLeafItem:(id)item
Parameters
item

The item to be checked.

Return Value

YES if the item is a leaf item; otherwise, NO.

Discussion

This method may return NO if the item has never been displayed in the browser or accessed via itemAtIndexPath:. Overriding this method has no effect. It may be used only if the browser’s delegate implements the item data source methods.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

isLoaded

Returns whether column 0 is loaded.

- (BOOL)isLoaded
Return Value

YES if column 0 is loaded; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

isOpaque

Indicates whether the browser is opaque.

- (BOOL)isOpaque
Return Value

YES when the browser doesn’t have a title and its background color’s alpha component is 1.0; otherwise, NO.

Discussion

This method overrides the isOpaque method of NSView.

Declared In
NSView.h

isTitled

Indicates whether columns display titles.

- (BOOL)isTitled
Return Value

YES if the columns in a browser display titles; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

itemAtIndexPath:

Returns the item at the specified index path.

- (id)itemAtIndexPath:(NSIndexPath *)indexPath
Parameters
indexPath

The index path of the item to return.

Return Value

The item.

Discussion

This method can only be used if the delegate implements the item data source methods. The specified index path must be displayable in the browser.

Availability
  • Available in OS X v10.6 and later.
Related Sample Code
Declared In
NSBrowser.h

itemAtRow:inColumn:

Returns the item located at the specified row and column.

- (id)itemAtRow:(NSInteger)row inColumn:(NSInteger)column
Parameters
row

The row of the item.

column

The column of the item.

Return Value

The item.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

lastColumn

Returns the index of the last column loaded.

- (NSInteger)lastColumn
Return Value

The index of the last loaded column.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

lastVisibleColumn

Returns the index of the last visible column.

- (NSInteger)lastVisibleColumn
Return Value

The index of the last visible column.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

loadColumnZero

Loads column 0; unloads previously loaded columns.

- (void)loadColumnZero
Availability
  • Available in OS X v10.0 and later.
Related Sample Code
Declared In
NSBrowser.h

loadedCellAtRow:column:

Loads, if necessary, and returns the cell at the specified row and column location.

- (id)loadedCellAtRow:(NSInteger)row column:(NSInteger)column
Parameters
row

The row index of the cell to return.

column

The column index of the cell to return.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

matrixClass

Returns the matrix class used in the browser’s columns.

- (Class)matrixClass
Return Value

The class of NSMatrix used in the browser's columns.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

matrixInColumn:

Returns the matrix located in the specified column.

- (NSMatrix *)matrixInColumn:(NSInteger)column
Parameters
column

The column index of the matrix to obtain.

Return Value

The matrix located in the column.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

maxVisibleColumns

Returns the maximum number of visible columns.

- (NSInteger)maxVisibleColumns
Return Value

The maximum number of visible columns.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

minColumnWidth

Returns the minimum column width.

- (CGFloat)minColumnWidth
Return Value

The minimum column width, in pixels.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

namesOfPromisedFilesDroppedAtDestination:

Provides the names of the files that the browser promises to create at a specified location.

- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
Return Value

Result of sending browser:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:inColumn: to the delegate.

Discussion

Implementation of the NSDraggingSource method namesOfPromisedFilesDroppedAtDestination:.

noteHeightOfRowsWithIndexesChanged:inColumn:

Immediately retiles the browser’s columns using row heights specified by the browser’s delegate.

- (void)noteHeightOfRowsWithIndexesChanged:(NSIndexSet *)indexSet inColumn:(NSInteger)columnIndex
Parameters
indexSet

The indexes of the rows to resize.

columnIndex

The column to retile.

Discussion

The browser’s delegate must implement

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

numberOfVisibleColumns

Returns the number of columns that are visible.

- (NSInteger)numberOfVisibleColumns
Return Value

The number of visible columns.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

parentForItemsInColumn:

Returns the item that contains the children located in the specified column.

- (id)parentForItemsInColumn:(NSInteger)column
Parameters
column

The column.

Return Value

The parent item for the specified column.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

path

Returns a string representing the browser’s current path.

- (NSString *)path
Return Value

The path representing the current selection. The components of this path are separated with the string returned by pathSeparator.

Discussion

Invoking this method is equivalent to invoking pathToColumn: for all columns.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

pathSeparator

Returns the path separator.

- (NSString *)pathSeparator
Return Value

The path separator. The default is “/”.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

pathToColumn:

Returns a string representing the path from the first column up to, but not including, the column at the given index.

- (NSString *)pathToColumn:(NSInteger)column
Parameters
column

The index of the column at which the path stops.

Return Value

The path of the current selection up to, but not including, the specified column. The components of this path are separated with the string returned by pathSeparator.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

prefersAllColumnUserResizing

Returns whether the browser is set to resize all columns simultaneously rather than resizing a single column at a time.

- (BOOL)prefersAllColumnUserResizing
Return Value

YES if the browser is set to resize all columns simultaneously; otherwise, NO. The default is NO.

Discussion

This setting applies only to browsers that allow the user to resize columns (see the constant NSBrowserUserColumnResizing. Holding down the Option key while resizing switches the type of resizing used.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

reloadColumn:

Reloads the given column.

- (void)reloadColumn:(NSInteger)column
Parameters
column

The index of the column to reload.

Discussion

If after reloading the selected item no longer exists in the column, the column is set to be the last column.

Availability
  • Available in OS X v10.0 and later.
Related Sample Code
Declared In
NSBrowser.h

reloadDataForRowIndexes:inColumn:

Updates the rows in the column with the specified column index with indexes in the specified set.

- (void)reloadDataForRowIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)column
Parameters
rowIndexes

The set of row indexes of the rows to be updated.

column

The column containing the rows to be updated.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

reusesColumns

Indicates whether the browser reuses matrix objects after their columns are unloaded.

- (BOOL)reusesColumns
Return Value

YES if NSMatrix objects aren't freed when their columns are unloaded; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

rowHeight

Returns the height of the browser’s rows.

- (CGFloat)rowHeight
Return Value

The row height.

Discussion

The default value is 17.0. rowHeight and setRowHeight: are only available when using the item delegate methods. An exception is thrown if you are using the matrix delegate methods.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

scrollColumnsLeftBy:

Scrolls columns left by the specified number of columns.

- (void)scrollColumnsLeftBy:(NSInteger)shiftAmount
Parameters
shiftAmount

The number of columns by which to scroll the browser.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

scrollColumnsRightBy:

Scrolls columns right by the specified number of columns.

- (void)scrollColumnsRightBy:(NSInteger)shiftAmount
Parameters
shiftAmount

The number of columns by which to scroll the browser.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

scrollColumnToVisible:

Scrolls to make the specified column visible.

- (void)scrollColumnToVisible:(NSInteger)column
Parameters
column

The index of the column to scroll to.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

scrollRowToVisible:inColumn:

Scrolls the specified row to be visible within the specified column.

- (void)scrollRowToVisible:(NSInteger)row inColumn:(NSInteger)column
Parameters
row

The index of the row to scroll.

column

The index of the column containing the row to scroll.

Discussion

The row’s column will not be scrolled to visible via this method. To scroll the column to visible, use scrollColumnToVisible:.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

selectAll:

Selects all cells in the last column of the browser.

- (void)selectAll:(id)sender
Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

selectedCell

Returns the last (rightmost and lowest) selected cell.

- (id)selectedCell
Return Value

The selected cell (NSCell). Returns nil if there is no selection.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

selectedCellInColumn:

Returns the last (lowest) cell selected in the given column.

- (id)selectedCellInColumn:(NSInteger)column
Parameters
column

The column whose last selected cell is to be returned.

Return Value

The last (or lowest) selected cell. Returns nil if there is no selection.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

selectedCells

Returns all cells selected in the rightmost column.

- (NSArray *)selectedCells
Return Value

An array of NSCell objects representing the selected cells in the rightmost browser column. Returns an empty array if there is no selection.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

selectedColumn

Returns the index of the last column with a selected item.

- (NSInteger)selectedColumn
Return Value

The index of the last column with a selected item, or -1 if there is no column selected.

Availability
  • Available in OS X v10.0 and later.
Related Sample Code
Declared In
NSBrowser.h

selectedRowInColumn:

Returns the row index of the selected cell in the specified column.

- (NSInteger)selectedRowInColumn:(NSInteger)column
Parameters
column

The column index specifying the column for which to return the selected row.

Return Value

The row index of the selected cell in the specified column. Returns -1 if there is no selection.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

selectedRowIndexesInColumn:

Provides the indexes of the selected rows in a given column of the browser.

- (NSIndexSet *)selectedRowIndexesInColumn:(NSInteger)columnIndex
Parameters
columnIndex

The column whose selected rows are provided.

Return Value

Rows selected in column columnIndex.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSBrowser.h

selectionIndexPath

Returns the index path of the item selected in the browser.

- (NSIndexPath *)selectionIndexPath
Return Value

The index path of the selected item, or nil if there is no selection.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

selectionIndexPaths

Returns an array containing the index paths of all items selected in the browser.

- (NSArray *)selectionIndexPaths
Return Value

The array containing the index paths of the selected items.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

selectRow:inColumn:

Selects the cell at the specified row and column index.

- (void)selectRow:(NSInteger)row inColumn:(NSInteger)column
Parameters
row

The row index of the cell to select.

column

The column index of the cell to select.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

selectRowIndexes:inColumn:

Specifies the selected rows in a given column of the browser.

- (void)selectRowIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)columnIndex
Parameters
rowIndexes

Rows to be selected in column columnIndex.

columnIndex

Column in which to select rows rowIndexes.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSBrowser.h

sendAction

Sends the action message to the target.

- (BOOL)sendAction
Return Value

YES if successful; NO if no target for the message could be found.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

sendsActionOnArrowKeys

Returns whether pressing an arrow key causes an action message to be sent.

- (BOOL)sendsActionOnArrowKeys
Return Value

NO if pressing an arrow key scrolls the browser; YES if it also sends the action message specified by setAction:.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

separatesColumns

Indicates whether columns are separated by bezeled borders.

- (BOOL)separatesColumns
Return Value

YES if the browser's columns are separated by bezeled borders; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setAllowsBranchSelection:

Allows the user to select branch items.

- (void)setAllowsBranchSelection:(BOOL)flag
Parameters
flag

YES if the user can select branch items when multiple selection is enabled; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setAllowsEmptySelection:

Allows the user to select nothing.

- (void)setAllowsEmptySelection:(BOOL)flag
Parameters
flag

YES if the browser allows an empty selection; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setAllowsMultipleSelection:

Allows the user to select multiple items.

- (void)setAllowsMultipleSelection:(BOOL)flag
Parameters
flag

YES if the user can select multiple items at once; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setAllowsTypeSelect:

Allows the browser to accept keystroke-based selection.

- (void)setAllowsTypeSelect:(BOOL)allowsTypeSelection
Parameters
allowsTypeSelection

YES to allow type selection; NO to disallow it.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSBrowser.h

setAutohidesScroller:

Allows the browser to hide its scroller automatically.

- (void)setAutohidesScroller:(BOOL)flag
Parameters
flag

If YES, the browser hides its scroller automatically; if NO, it does not.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

setBackgroundColor:

Specifies the browser’s background color.

- (void)setBackgroundColor:(NSColor *)backgroundColor
Parameters
backgroundColor

[NSColor clearColor] specifies a transparent background.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSBrowser.h

setCellClass:

Sets the class of the cell to be used by the matrices in the columns of the browser.

- (void)setCellClass:(Class)factoryId
Parameters
factoryId

The class of NSCell used by the matrices in the columns of the browser. This method creates an instance of the class and calls setCellPrototype:.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setCellPrototype:

Sets the prototype cell for displaying items in the matrices in the columns of the browser.

- (void)setCellPrototype:(NSCell *)aCell
Parameters
aCell

The prototype NSCell instance.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setColumnResizingType:

Sets the browser’s column resizing type.

- (void)setColumnResizingType:(NSBrowserColumnResizingType)columnResizingType
Parameters
columnResizingType

The column resizing type. Possible values are described in “NSBrowserColumnResizingType”. The default is NSBrowserAutoColumnResizing. This setting is persistent.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

setColumnsAutosaveName:

Sets the name used to automatically save the browser’s column configuration.

- (void)setColumnsAutosaveName:(NSString *)name
Parameters
name

The name used to save the column configuration. If name is different from the current name, this method also reads in any column configuration data previously saved under name and applies the values to the browser.

Discussion

Column configuration is defined as an array of column content widths. One width is saved for each level the user has reached. That is, the browser saves column width based on depth, not on unique paths. To do more complex column persistence, you should register for NSBrowserColumnConfigurationDidChangeNotification and handle persistence yourself. This setting is persistent.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

setDefaultColumnWidth:

Sets the default column width for new browser columns that do not otherwise have an initial width from defaults or the browser’s delegate.

- (void)setDefaultColumnWidth:(CGFloat)columnWidth
Parameters
columnWidth

The default column width to set.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

setDelegate:

Sets the browser’s delegate.

- (void)setDelegate:(id <NSBrowserDelegate>)anObject
Parameters
anObject

The object to set at the browser's delegate.

Availability
  • Available in OS X v10.0 and later.
See Also
Declared In
NSBrowser.h

setDoubleAction:

Sets the browser’s double-click action.

- (void)setDoubleAction:(SEL)aSelector
Parameters
aSelector

The action method to invoke when the browser is double-clicked.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setDraggingSourceOperationMask:forLocal:

Specifies the drag-operation mask for dragging operations with local or external destinations.

- (void)setDraggingSourceOperationMask:(NSDragOperation)dragOperationMask forLocal:(BOOL)localDestination
Parameters
dragOperationMask

Dragging operation mask to use for either local or external drag operations, as specified by localDestination.

localDestination

Indicates the location of the dragging operation’s destination object:

YES for this application; NO for another application.

Discussion

Availability
  • Available in OS X v10.5 and later.
Declared In
NSBrowser.h

setHasHorizontalScroller:

Sets whether the browser has a scroller to scroll horizontally.

- (void)setHasHorizontalScroller:(BOOL)flag
Parameters
flag

YES if the browser uses an NSScroller object to scroll horizontally; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setLastColumn:

Sets the last column.

- (void)setLastColumn:(NSInteger)column
Parameters
column

The index of the last column.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setMatrixClass:

Sets the matrix class to be used in the browser’s columns.

- (void)setMatrixClass:(Class)factoryId
Parameters
factoryId

The matrix class (NSMatrix or an NSMatrix subclass) used in the browser's columns.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setMaxVisibleColumns:

Sets the maximum number of columns that can be displayed.

- (void)setMaxVisibleColumns:(NSInteger)columnCount
Parameters
columnCount

The maximum number of visible columns.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setMinColumnWidth:

Sets the minimum column width.

- (void)setMinColumnWidth:(CGFloat)columnWidth
Parameters
columnWidth

The minimum column width, in pixels.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setPath:

Sets the path to be displayed by the browser.

- (BOOL)setPath:(NSString *)path
Parameters
path

The path to display. If path is prefixed by the path separator, the path is absolute, containing the full path from the browser’s first column. Otherwise, the path is relative, extending the browser’s current path starting at the last column.

Return Value

YES if the given path is valid; otherwise, NO.

Discussion

While parsing path, the browser compares each component with the entries in the current column. If an exact match is found, the matching entry is selected, and the next component is compared to the next column’s entries. If no match is found for a component, the method exits and returns NO; the final path is set to the valid portion of path. If each component of path specifies a valid branch or leaf in the browser’s hierarchy, the method returns YES.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setPathSeparator:

Sets the path separator.

- (void)setPathSeparator:(NSString *)newString
Parameters
newString

The new path separator.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setPrefersAllColumnUserResizing:

Causes the browser to resize all column simultaneously rather than resize a single column at a time.

- (void)setPrefersAllColumnUserResizing:(BOOL)prefersAllColumnResizing
Parameters
prefersAllColumnResizing

YES to cause the browser to resize all columns simultaneously; the default is single column resizing (NO). This setting applies only to browsers that allow the user to resize columns (see NSBrowserUserColumnResizing. Holding down the Option key while resizing switches the type of resizing used. This setting is persistent.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

setReusesColumns:

Specifies whether matrices can be reused.

- (void)setReusesColumns:(BOOL)flag
Parameters
flag

YES to prevent NSMatrix objects from being freed when their columns are unloaded, so they can be reused; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setRowHeight:

Sets the height of the browser’s rows to the specified value.

- (void)setRowHeight:(CGFloat)height
Parameters
height

The new height to set.

Discussion

The value must be greater than 0. Any fractional value will be forced to an integral value for drawing. For variable row height browsers (ones whose delegates implement browser:heightOfRow:inColumn:), the row height will be used to draw alternating rows past the last row in each browser column. rowHeight and setRowHeight: are only available when using the item delegate methods. An exception is thrown if you are using the matrix delegate methods.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

setSelectionIndexPath:

Sets the browser’s selection to the item with the specified path.

- (void)setSelectionIndexPath:(NSIndexPath *)path
Parameters
path

The path of the item to select.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

setSelectionIndexPaths:

Sets the browser’s selection to the items whose index paths are in the specified array.

- (void)setSelectionIndexPaths:(NSArray *)paths
Parameters
paths

The array containing the index paths of the items to select.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSBrowser.h

setSendsActionOnArrowKeys:

Allows the specified action message to be sent when the user presses an arrow key.

- (void)setSendsActionOnArrowKeys:(BOOL)flag
Parameters
flag

YES if pressing an arrow key should send the action message specified by setAction: in addition to scrolling the browser; NO if it should only scroll the browser.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setSeparatesColumns:

Separates columns with bezeled borders.

- (void)setSeparatesColumns:(BOOL)flag
Parameters
flag

YES if the browser's columns should be separated by bezeled borders; otherwise, NO. This value is ignored if isTitled does not return NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setTakesTitleFromPreviousColumn:

Sets whether the title of a column is set to the string value of the selected cell in the previous column.

- (void)setTakesTitleFromPreviousColumn:(BOOL)flag
Parameters
flag

YES if the title of a column should be set to the string value of the selected NSCell in the previous column; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setTitle:ofColumn:

Sets the title of the given column.

- (void)setTitle:(NSString *)aString ofColumn:(NSInteger)column
Parameters
aString

The title of the column.

column

The index of the column whose title should be set.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

setTitled:

Sets columns to display titles.

- (void)setTitled:(BOOL)flag
Parameters
flag

YES if the columns in a browser display titles; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
See Also
Declared In
NSBrowser.h

setWidth:ofColumn:

Sets the width of the specified column.

- (void)setWidth:(CGFloat)columnWidth ofColumn:(NSInteger)columnIndex
Parameters
columnWidth

The new width of the specified column.

columnIndex

The index of the column for which to set the width.

Discussion

This method can be used to set the initial width of browser columns unless the column sizing is automatic; setWidth:ofColumn: does nothing if columnResizingType is NSBrowserAutoColumnResizing. To set the default width for new columns (that don’t otherwise have initial widths from defaults or via the delegate), use a columnIndex of –1. A value set for columnIndex of –1 is persistent. An NSBrowserColumnConfigurationDidChangeNotification notification is posted (not immediately), if necessary, so that the browser can autosave the new column configuration.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

takesTitleFromPreviousColumn

Indicates whether a column takes its title from the selected cell in the previous column.

- (BOOL)takesTitleFromPreviousColumn
Return Value

YES if the title of a column is set to the string value of the selected NSCell in the previous column; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

tile

Adjusts the various subviews of the browser—scrollers, columns, titles, and so on—without redrawing.

- (void)tile
Discussion

Your code shouldn’t send this message. It’s invoked any time the appearance of the browser changes.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

titleFrameOfColumn:

Returns the bounds of the title frame for the specified column.

- (NSRect)titleFrameOfColumn:(NSInteger)column
Parameters
column

The index of the column for which to return the title frame.

Return Value

The rectangle specifying the bounds of the column's title frame.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

titleHeight

Returns the height of the column titles.

- (CGFloat)titleHeight
Return Value

The height of the column titles for the browser.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

titleOfColumn:

Returns the title displayed for the given column.

- (NSString *)titleOfColumn:(NSInteger)column
Parameters
column

The index of the column for which to get the title.

Return Value

The title of the specified column.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

validateVisibleColumns

Validates the browser’s visible columns.

- (void)validateVisibleColumns
Discussion

This method invokes the delegate method browser:isColumnValid:

Availability
  • Available in OS X v10.0 and later.
Declared In
NSBrowser.h

widthOfColumn:

Returns the width of the specified column.

- (CGFloat)widthOfColumn:(NSInteger)column
Parameters
column

The index of the column for which to retrieve the width.

Return Value

The width of the column.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSBrowser.h

Constants

NSBrowserColumnResizingType

Types of browser column resizing.

enum {
   NSBrowserNoColumnResizing   = 0,
   NSBrowserAutoColumnResizing = 1,
   NSBrowserUserColumnResizing = 2
};
typedef NSUInteger NSBrowserColumnResizingType;
Constants
NSBrowserNoColumnResizing

Neither NSBrowser nor the user can change the column width. The developer must explicitly set all column widths.

Available in OS X v10.3 and later.

Declared in NSBrowser.h.

NSBrowserAutoColumnResizing

All columns have the same width, calculated using a combination of the minimum column width and maximum number of visible columns settings. The column width changes as the window size changes. The user cannot resize columns.

Available in OS X v10.3 and later.

Declared in NSBrowser.h.

NSBrowserUserColumnResizing

The developer chooses the initial column widths, but users can resize all columns simultaneously or each column individually.

Available in OS X v10.3 and later.

Declared in NSBrowser.h.

Discussion

These constants are used by the setColumnResizingType: and columnResizingType methods.

NSBrowserDropOperation

The type used to specify the drop type of a drag-and-drop operation. See browser:validateDrop:proposedRow:column:dropOperation: for more information.

   
enum {
   NSBrowserDropOn,
   NSBrowserDropAbove
};
typedef NSUInteger NSBrowserDropOperation;
Constants
NSBrowserDropOn

The drop occurs at the row to which the item was dragged.

Available in OS X v10.5 and later.

Declared in NSBrowser.h.

NSBrowserDropAbove

The drop occurs above the row to which the item was dragged.

Available in OS X v10.5 and later.

Declared in NSBrowser.h.

Declared In
NSBrowser.h

Application Kit Versions for NSBrowser Functionality

The version of the AppKit.framework containing a specific bug fix or capability.

#define NSAppKitVersionNumberWithContinuousScrollingBrowser 680.0
#define NSAppKitVersionNumberWithColumnResizingBrowser      685.0
Constants
NSAppKitVersionNumberWithContinuousScrollingBrowser

The specific version of the AppKit framework that introduced support the continuous scrolling in NSBrowser. Developers should not need to use this constant unless they are writing applications for OS X v10.3 and earlier.

Available in OS X v10.3 and later.

Declared in NSBrowser.h.

NSAppKitVersionNumberWithColumnResizingBrowser

The specific version of the AppKit framework that introduced support for resizing individual browser columns. Developers should not need to use this constant unless they are writing applications for OS X v10.3 and earlier.

Available in OS X v10.3 and later.

Declared in NSBrowser.h.

Notifications

NSBrowserColumnConfigurationDidChangeNotification

Notifies the delegate when the width of a browser column has changed. The notification object is the browser whose column sizes need to be made persistent. This notification does not contain a userInfo dictionary. If the user resizes more than one column, a single notification is posted when the user is finished resizing.
Availability
See Also
Declared In
NSBrowser.h