Inherits From:
NSControl : NSView : NSResponder : NSObject
Conforms To:
NSCoding (NSResponder)
NSObject (NSObject)
Declared In:
AppKit/NSBrowser.h
addColumn
message, which messages its delegate to load the next column. The user's selection can be represented as a character string; if the selection is hierarchical (for example, a filename within a directory), each component of the path to the selected node is separated by "/". To use some other character as the delimiter, invoke setPathSeparator:
.An NSBrowser can be set to allow selection of multiple entries in a column, or to limit selection to a single entry. When set for multiple selection, it can also be set to limit multiple selection to leaf nodes only, or to allow selection of both types of nodes together.
As a subclass of NSControl, NSBrowser has a target object and action message. Each time the user selects one or more entries in a column, the action message is sent to the target. NSBrowser also adds an action to be sent when the user double-clicks on an entry, which allows the user to select items without any action being taken, and then double-click to invoke some useful action such as opening a file.
You can implement one of two delegate types: active or passive. An active delegate creates a column's rows (that is, the NSBrowserCells) itself, while a passive one leaves that job to the NSBrowser. Normally, passive delegates are preferable, because they're easier to implement. An active delegate must implement browser:createRowsForColumn:inMatrix:
to create the rows of the specified column. A passive delegate, on the other hand, must implement browser:
numberOfRowsInColumn
:
to let the NSBrowser know how many rows to create. These two methods are mutually exclusive; you can implement one or the other, but not both. (The NSBrowser ascertains what type of delegate it has by which method the delegate responds to.)
Both types of delegate implement browser:
willDisplayCell:atRow:column:
to set up state (such as the cell's string value and whether the cell is a leaf or a branch) before an individual cell is displayed. (This delegate method doesn't need to invoke NSBrowserCell's setLoaded:
method, because the NSBrowser can determine that state by itself.) An active delegate can instead set all the cells' state at the time the cells are created, in which case it doesn't need to implement browser:willDisplayCell:atRow:column:
. However, a passive delegate must always implement this method.
cellClass
Returns the NSBrowserCell class (regardless of whether a setCellClass:
message has been sent to a particular instance)
See also:
- cellPrototype
,- setCellPrototype:
acceptsArrowKeys
Returns YES if the arrow keys are enabled.
See also:
- setAcceptsArrowKeys:
addColumn
Adds a column to the right of the last column.
See also:
- columnOfMatrix:
, - displayColumn:
, - selectedColumn
allowsBranchSelection
Returns whether the user can select branch items when multiple selection is enabled.
See also:
- setAllowsBranchSelection:
allowsEmptySelection
Returns whether there can be nothing selected.
See also:
- setAllowsEmptySelection:
allowsMultipleSelection
Returns whether the user can select multiple items.
See also:
- setAllowsMultipleSelection:
cellPrototype
Returns the NSBrowser's prototype NSCell.
See also:
- setCellPrototype:
, - setCellClass:
columnOfMatrix:
(NSMatrix *)matrix
Returns the column number in which matrix is located.
See also:
- matrixInColumn:
delegate
Returns the NSBrowser's delegate.
See also:
- setDelegate:
displayAllColumns
Updates the NSBrowser to display all loaded columns.
See also:
- addColumn
, - validateVisibleColumns
displayColumn:
(int)column
Updates the NSBrowser to display the column with the given index.
See also:
- addColumn
, - validateVisibleColumns
doClick:
(id)sender
Responds to (single) mouse clicks in a column of the NSBrowser.
See also:
- sendAction
doDoubleClick:
(id)sender
Responds to double-clicks in a column of the NSBrowser.
See also:
- setDoubleAction:
doubleAction
Returns the NSBrowser's double-click action method.
See also:
- setDoubleAction:
drawTitleOfColumn:
(int)column inRect:
(NSRect)aRect
Draws the title for the column at index column within the rectangle defined by aRect.
See also:
- setTitle:ofColumn:
, - titleFrameOfColumn:
, - titleHeight
firstVisibleColumn
Returns the index of the first visible column.
See also:
- lastVisibleColumn
, - numberOfVisibleColumns
frameOfColumn:
(int)column
Returns the rectangle containing the column at index column.
frameOfInsideOfColumn:
(int)column
Returns the rectangle containing the column at index column, not including borders.
hasHorizontalScroller
Returns whether an NSScroller is used to scroll horizontally.
See also:
- setHasHorizontalScroller:
isLoaded
Returns whether column zero is loaded.
See also:
- loadColumnZero
, - reloadColumn:
isTitled
Returns whether columns display titles.
See also:
- setTitled:
lastColumn
Returns the index of the last column loaded.
See also:
- selectedColumn
, - setLastColumn:
lastVisibleColumn
Returns the index of the last visible column.
See also:
- firstVisibleColumn
, - numberOfVisibleColumns
loadColumnZero
Loads column zero; unloads previously loaded columns.
See also:
- isLoaded
, - reloadColumn:
loadedCellAtRow:
(int)row column:
(int)column
Loads if necessary and returns the NSCell at row in column.
See also:
- selectedCellInColumn:
matrixClass
Returns the class of NSMatrix used in the NSBrowser's columns.
See also:
- setMatrixClass:
matrixInColumn:
(int)column
Returns the matrix located in the column identified by index column.
maxVisibleColumns
Returns the maximum number of visible columns.
See also:
- setMaxVisibleColumns:
minColumnWidth
Returns the minimum column width in pixels.
See also:
- setMinColumnWidth:
numberOfVisibleColumns
Returns the number of columns visible.
See also:
- validateVisibleColumns
path
Returns the browser's current path.
See also:
- setPath:
pathSeparator
Returns the path separator. The default is "/".
See also:
- setPathSeparator:
pathToColumn:
(int)column
Returns a string representing the path from the first column up to, but not including, the column at index column.
See also:
- path
, - setPath:
reloadColumn:
(int)column
Reloads column if it is loaded; sets it as the last column.
See also:
- isLoaded
, - loadColumnZero
reusesColumns
Returns YES if NSMatrix objects aren't freed when their columns are unloaded.
See also:
- setReusesColumns:
scrollColumnToVisible:
(int)column
Scrolls to make the column at index column visible.
See also:
- scrollViaScroller:
, - updateScroller
scrollColumnsLeftBy:
(int)shiftAmount
Scrolls columns left by shiftAmount columns.
See also:
- scrollViaScroller:
, - updateScroller
scrollColumnsRightBy:
(int)shiftAmount
Scrolls columns right by shiftAmount columns.
See also:
- scrollViaScroller:
, - updateScroller
scrollViaScroller:
(NSScroller *)sender
Scrolls columns left or right based on an NSScroller.
See also:
- updateScroller
selectAll:
(id)sender
Selects all NSCells in the last column of the NSBrowser.
See also:
- selectedCell
, - selectedCells
, - selectedColumn
selectRow:
(int)row inColumn:
(int)column
Selects the cell at index row in the column identified by index column.
See also:
- loadedCellAtRow:column:
, - selectedRowInColumn:
selectedCell
Returns the last (rightmost and lowest) selected NSCell.
See also:
- loadedCellAtRow:column:
, - selectedCells
, - selectRow:inColumn:
selectedCellInColumn:
(int)column
Returns the last (lowest) NSCell that's selected in column.
See also:
- loadedCellAtRow:column:
, - selectedCell
, - selectedRowInColumn:
selectedCells
Returns all cells selected in the rightmost column.
See also:
- selectAll:
, - selectedCell
selectedColumn
Returns the index of the last column with a selected item.
See also:
- columnOfMatrix:
, - selectAll:
selectedRowInColumn:
(int)column
Returns the row index of the selected cell in the column specified by index column.
See also:
- loadedCellAtRow:column:
, - selectedCell
, - selectedCellInColumn:
sendAction
Sends the action message to the target. Returns YES upon success, NO if no target for the message could be found.
sendsActionOnArrowKeys
Returns NO if pressing an arrow key only scrolls the browser, YES if it also sends the action message specified by setAction:
.
See also:
- acceptsArrowKeys
, - setSendsActionOnArrowKeys:
separatesColumns
Returns whether columns are separated by bezeled borders.
See also:
- setSeparatesColumns:
setAcceptsArrowKeys:
(BOOL)flag
Enables or disables the arrow keys as used for navigating within and between browsers.
See also:
- acceptsArrowKeys
, - sendsActionOnArrowKeys
setAllowsBranchSelection:
(BOOL)flag
Sets whether the user can select branch items when multiple selection is enabled.
See also:
- allowsBranchSelection
setAllowsEmptySelection:
(BOOL)flag
Sets whether there can be nothing selected.
See also:
- allowsEmptySelection
setAllowsMultipleSelection:
(BOOL)flag
Sets whether the user can select multiple items.
See also:
- allowsMultipleSelection
setCellClass:
(Class)factoryId
Sets the class of NSCell used in the columns of the NSBrowser.
See also:
+ cellClass
, - cellPrototype
setCellPrototype:
(NSCell *)aCell
Sets the NSCell instance copied to display items in the columns of NSBrowser.
See also:
+ cellClass
, - cellPrototype
setDelegate:
(id)anObject
Sets the NSBrowser's delegate to anObject. Raises NSBrowserIllegalDelegateException if the delegate specified by anObject doesn't respond to browser:willDisplayCell:atRow:column:
and either of the methods browser:numberOfRowsInColumn:
or browser:createRowsForColumn:inMatrix:
.
See also:
- delegate
setDoubleAction:
(SEL)aSelector
Sets the NSBrowser's double-click action to aSelector.
See also:
- doubleAction
, - sendAction
setHasHorizontalScroller:
(BOOL)flag
Sets whether an NSScroller is used to scroll horizontally.
See also:
- hasHorizontalScroller
setLastColumn:
(int)column
Sets the last column to column.
See also:
- lastColumn
, - lastVisibleColumn
setMatrixClass:
(Class)factoryId
Sets the matrix class (NSMatrix or an NSMatrix subclass) used in the NSBrowser's columns.
See also:
- matrixClass
setMaxVisibleColumns:
(int)columnCount
Sets the maximum number of columns displayed.
See also:
- maxVisibleColumns
setMinColumnWidth:
(float)columnWidth
Sets the minimum column width in pixels.
See also:
- minColumnWidth
setPath:
(NSString *)path
Parses path and selects corresponding items in the NSBrowser columns.
See also:
- path
, - pathToColumn:
setPathSeparator:
(NSString *)newString
Sets the path separator to newString.
See also:
- pathSeparator
setReusesColumns:
(BOOL)flag
If flag is YES, prevents NSMatrix objects from being freed when their columns are unloaded, so they can be reused.
See also:
- reusesColumns
setSendsActionOnArrowKeys:
(BOOL)flag
Sets whether pressing an arrow key will cause the action message to be sent (in addition to causing scrolling).
See also:
- sendsActionOnArrowKeys
setSeparatesColumns:
(BOOL)flag
Sets whether to separate columns with bezeled borders.
See also:
- separatesColumns
setTakesTitleFromPreviousColumn:
(BOOL)flag
Sets whether the title of a column is set to the string value of the selected NSCell in the previous column.
See also:
- takesTitleFromPreviousColumn
setTitle:
(NSString *)aString ofColumn:
(int)column
Sets the title of the column at index column to aString.
See also:
- drawTitleOfColumn:inRect:
, - titleOfColumn:
setTitled:
(BOOL)flag
Sets whether columns display titles.
See also:
- isTitled
takesTitleFromPreviousColumn
Returns YES if the title of a column is set to the string value of the selected NSCell in the previous column.
See also:
- setTakesTitleFromPreviousColumn:
tile
Adjusts the various subviews of NSBrowser-scrollers, columns, titles, and so on-without redrawing. Your code shouldn't send this message. It's invoked any time the appearance of the NSBrowser changes.
titleFrameOfColumn:
(int)column
Returns the bounds of the title frame for the column at index column.
See also:
- drawTitleOfColumn:inRect:
titleHeight
Returns the height of column titles.
See also:
- drawTitleOfColumn:inRect:
titleOfColumn:
(int)column
Returns the title displayed for the column at index column.
See also:
- setTitle:ofColumn:
updateScroller
Updates the horizontal scroller to reflect column positions.
See also:
- scrollViaScroller:
validateVisibleColumns
Invokes delegate method browser:isColumnValid:
for visible columns.
See also:
- numberOfVisibleColumns
Methods Implemented By the Delegate
browser:
(NSBrowser *)sendercreateRowsForColumn:
(int)columninMatrix:
(NSMatrix *)matrix
Creates a row in matrix for each row of data to be displayed in column of the browser. Either this method or browser:numberOfRowsInColumn:
must be implemented, but not both (or an NSBrowserIllegalDelegateException will be raised).
See also:
- browser:willDisplayCell:atRow:column:
browser:
(NSBrowser *)sender isColumnValid:
(int)column
Returns whether the contents of the specified column are valid. If NO is returned, sender reloads the column. This method is invoked in response to validateVisibleColumns
being sent to sender.
browser:
(NSBrowser *)sender numberOfRowsInColumn:
(int)column
Returns the number of rows of data in the column at index column. Either this method or browser:createRowsForColumn:inMatrix:
must be implemented, but not both.
See also:
- browser:willDisplayCell:atRow:column:
browser:
(NSBrowser *)sender selectCellWithString:
(NSString *)titleinColumn:
(int)column
Asks the delegate to select the NSCell with title title in the column at index column. If the delegate returns NO, the NSCell is not selected.
See also:
- selectedCellInColumn:
browser:
(NSBrowser *)senderselectRow:
(int)rowinColumn:
(int)column
Asks the delegate to select the NSCell at row row in the column at index column. If the delegate returns NO, the NSCell is not selected.
See also:
- selectedRowInColumn:
, - selectRow:inColumn:
browser:
(NSBrowser *)sender titleOfColumn:
(int)column
Asks the delegate for the title to display above the column at index column.
See also:
- setTitle:ofColumn:
, - titleOfColumn:
browser:
(NSBrowser *)sender willDisplayCell:
(id)cell atRow:
(int)row column:
(int)column
Notifies the delegate before the NSBrowser displays the specified cell at row in column. The delegate should set any state necessary for the correct display of the cell.
See also:
- browser:createRowsForColumn:inMatrix:,
- browser:numberOfRowsInColumn:
browserDidScroll:
(NSBrowser *)sender
Notifies the delegate when the NSBrowser has scrolled.
browserWillScroll:
(NSBrowser *)sender
Notifies the delegate when the NSBrowser will scroll.