Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Next Page > Hide TOC

NSBrowser Class Reference

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

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

Scrolling

Dragging

Getting Column Frames

Managing Actions

Handling Mouse-Click Events

Sizing

Displaying Expansion Tooltips

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
See Also
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
See Also
Declared In
NSBrowser.h

Instance Methods

acceptsArrowKeys

Returns a Boolean value indicating whether the browser allows navigation using the arrow keys.

- (BOOL)acceptsArrowKeys

Return Value

YES if the arrow keys are enabled; otherwise NO.

Availability
See Also
Declared In
NSBrowser.h

addColumn

Adds a column to the right of the last column.

- (void)addColumn

Availability
See Also
Declared In
NSBrowser.h

allowsBranchSelection

Returns a Boolean value indicating 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
See Also
Declared In
NSBrowser.h

allowsEmptySelection

Returns a Boolean value indicating whether there can be nothing selected.

- (BOOL)allowsEmptySelection

Return Value

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

Availability
See Also
Declared In
NSBrowser.h

allowsMultipleSelection

Returns a Boolean value indicating 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
See Also
Declared In
NSBrowser.h

allowsTypeSelect

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

- (BOOL)allowsTypeSelect

Return Value

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

Availability
See Also
Declared In
NSBrowser.h

backgroundColor

Provides the receiver’s background color. Default: [NSColor whiteColor].

- (NSColor *)backgroundColor

Return Value

The receiver’s background color.

Default: [NSColor whiteColor]

Availability
See Also
Declared In
NSBrowser.h

canDragRowsWithIndexes:inColumn:withEvent:

Indicates whether the receiver 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, NO otherwise.

Availability
See Also
Declared In
NSBrowser.h

cellPrototype

Returns the receiver’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
See Also
Declared In
NSBrowser.h

columnContentWidthForColumnWidth:

Given the column width, returns the content 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
See Also
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
See Also
Declared In
NSBrowser.h

columnResizingType

Returns the receiver’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
See Also
Declared In
NSBrowser.h

columnsAutosaveName

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

- (NSString *)columnsAutosaveName

Return Value

The name used to save the column configuration.

Availability
See Also
Declared In
NSBrowser.h

columnWidthForColumnContentWidth:

Given the content width, returns the column width.

- (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
See Also
Declared In
NSBrowser.h

delegate

Returns the receiver’s delegate.

- (id)delegate

Return Value

The receiver's delegate.

Availability
See Also
Declared In
NSBrowser.h

displayAllColumns

Updates the receiver to display all loaded columns.

- (void)displayAllColumns

Availability
See Also
Declared In
NSBrowser.h

displayColumn:

Updates the receiver to display the given column.

- (void)displayColumn:(NSInteger)column

Parameters
column

The index of the column to display.

Availability
See Also
Declared In
NSBrowser.h

doClick:

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

- (void)doClick:(id)sender

Availability
See Also
Declared In
NSBrowser.h

doDoubleClick:

Responds to double clicks in a column of the receiver.

- (void)doDoubleClick:(id)sender

Availability
See Also
Declared In
NSBrowser.h

doubleAction

Returns the receiver’s double-click action method.

- (SEL)doubleAction

Return Value

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

Availability
See Also
Declared In
NSBrowser.h

draggingImageForRowsWithIndexes:inColumn:withEvent:offset:

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

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

inout_dragImageOffset

Offset for the returned image:

Return Value

Image representing the visible cells identified by rowIndexes.

Availability
See Also
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

NSDragOperationEvery when localDestination is YES.

NSDragOperationNone when localDestination is NO.

Discussion

This method overrides NSDraggingSource 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
See Also
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
See Also
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
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
Declared In
NSBrowser.h

hasHorizontalScroller

Returns a Boolean value indicating 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
See Also
Declared In
NSBrowser.h

isLoaded

Returns whether column 0 is loaded.

- (BOOL)isLoaded

Return Value

YES if column 0 is loaded; otherwise NO.

Availability
See Also
Declared In
NSBrowser.h

isOpaque

Indicates whether the receiver is opaque.

- (BOOL)isOpaque

Return Value

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

Discussion

This method overrides NSView isOpaque.

isTitled

Returns a Boolean value indicating whether columns display titles.

- (BOOL)isTitled

Return Value

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

Availability
See Also
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
See Also
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
See Also
Declared In
NSBrowser.h

loadColumnZero

Loads column 0; unloads previously loaded columns.

- (void)loadColumnZero

Availability
See Also
Declared In
NSBrowser.h

loadedCellAtRow:column:

Loads, if necessary, and returns the NSCell 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
See Also
Declared In
NSBrowser.h

matrixClass

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