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 |
Related sample code |
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:
Columns
Scroll views
Matrices
Browser cells
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..*] |
– reusesColumns
– setReusesColumns:
– maxVisibleColumns
– setMaxVisibleColumns:
– backgroundColor
– setBackgroundColor:
– minColumnWidth
– setMinColumnWidth:
– separatesColumns
– setSeparatesColumns:
– takesTitleFromPreviousColumn
– setTakesTitleFromPreviousColumn:
– tile
– acceptsArrowKeys
– setAcceptsArrowKeys:
– delegate
– setDelegate:
– isOpaque
– browser:isColumnValid:
delegate method
– browser:numberOfRowsInColumn:
delegate method
– browser:titleOfColumn:
delegate method
– allowsBranchSelection
– setAllowsBranchSelection:
– allowsEmptySelection
– setAllowsEmptySelection:
– allowsMultipleSelection
– setAllowsMultipleSelection:
– selectedRowIndexesInColumn:
– selectRowIndexes:inColumn:
– allowsTypeSelect
– setAllowsTypeSelect:
– browser:shouldTypeSelectForEvent:withCurrentSearchString:
delegate method
– browser:typeSelectStringForRow:inColumn:
delegate method
– browser:nextTypeSelectMatchFromRow:toRow:inColumn:forString:
delegate method
– selectedCell
– selectedCellInColumn:
– selectedCells
– selectAll:
– selectedRowInColumn:
– selectRow:inColumn:
– browser:selectCellWithString:inColumn:
delegate method
– browser:selectRow:inColumn:
delegate method
– addColumn
– displayAllColumns
– displayColumn:
– columnOfMatrix:
– selectedColumn
– lastColumn
– setLastColumn:
– firstVisibleColumn
– numberOfVisibleColumns
– lastVisibleColumn
– validateVisibleColumns
– isLoaded
– loadColumnZero
– reloadColumn:
– browser:createRowsForColumn:inMatrix:
delegate method
– browser:willDisplayCell:atRow:column:
delegate method
– titleOfColumn:
– setTitle:ofColumn:
– isTitled
– setTitled:
– drawTitleOfColumn:inRect:
– titleHeight
– titleFrameOfColumn:
– updateScroller
– hasHorizontalScroller
– setHasHorizontalScroller:
– scrollColumnToVisible:
– scrollColumnsLeftBy:
– scrollColumnsRightBy:
– scrollViaScroller:
– browserWillScroll:
delegate method
– browserDidScroll:
delegate method
– draggingSourceOperationMaskForLocal:
– setDraggingSourceOperationMask:forLocal:
– canDragRowsWithIndexes:inColumn:withEvent:
– browser:canDragRowsWithIndexes:inColumn:withEvent:
delegate method
– draggingImageForRowsWithIndexes:inColumn:withEvent:offset:
– browser:draggingImageForRowsWithIndexes:inColumn:withEvent:offset:
delegate method
– browser:validateDrop:proposedRow:column:dropOperation:
delegate method
– browser:acceptDrop:atRow:column:dropOperation:
delegate method
– namesOfPromisedFilesDroppedAtDestination:
– browser:writeRowsWithIndexes:inColumn:toPasteboard:
delegate method
– browser:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:inColumn:
delegate method
– doubleAction
– setDoubleAction:
– sendsActionOnArrowKeys
– setSendsActionOnArrowKeys:
– sendAction
+ removeSavedColumnsWithAutosaveName:
– columnsAutosaveName
– setColumnsAutosaveName:
– columnContentWidthForColumnWidth:
– columnWidthForColumnContentWidth:
– columnResizingType
– setColumnResizingType:
– prefersAllColumnUserResizing
– setPrefersAllColumnUserResizing:
– widthOfColumn:
– setWidth:ofColumn:
– browser:shouldSizeColumn:forUserResize:toWidth:
delegate method
– browser:sizeToFitWidthOfColumn:
delegate method
– browserColumnConfigurationDidChange:
delegate method
– browser:shouldShowCellExpansionForRow:column:
delegate method
Returns the NSBrowserCell
class.
+ (Class)cellClass
Always returns the NSBrowserCell
class (even if the developer has sent a setCellClass:
message to a particular instance).
This method is used by NSControl
during initialization and is not meant to be used by applications.
NSBrowser.h
Removes the column configuration data stored under the given name from the application’s user defaults.
+ (void)removeSavedColumnsWithAutosaveName:(NSString *)name
The name of the column configuration data to remove.
NSBrowser.h
Returns a Boolean value indicating whether the browser allows navigation using the arrow keys.
- (BOOL)acceptsArrowKeys
YES
if the arrow keys are enabled; otherwise NO
.
NSBrowser.h
Adds a column to the right of the last column.
- (void)addColumn
NSBrowser.h
Returns a Boolean value indicating whether the user can select branch items.
- (BOOL)allowsBranchSelection
YES
if the user can select branch items when multiple selection is enabled; otherwise NO
.
NSBrowser.h
Returns a Boolean value indicating whether there can be nothing selected.
- (BOOL)allowsEmptySelection
YES
if the browser allows the selection to be empty; otherwise NO
.
NSBrowser.h
Returns a Boolean value indicating whether the user can select multiple items.
- (BOOL)allowsMultipleSelection
YES
if the browser allows the user to select multiple items at once; otherwise NO
.
NSBrowser.h
Indicates whether the receiver allows keystroke-based selection (type select).
- (BOOL)allowsTypeSelect
YES
(default) when the receiver allows keystroke-based selection, NO
otherwise.
NSBrowser.h
Provides the receiver’s background color. Default: [NSColor whiteColor].
- (NSColor *)backgroundColor
The receiver’s background color.
Default: [NSColor whiteColor]
NSBrowser.h
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
Rows the user is dragging
Column containing the rows the user is dragging.
Mouse-drag event.
YES
when rowIndexes identifies at least one row and all the identified rows are enabled, NO
otherwise.
NSBrowser.h
Returns the receiver’s prototype NSCell
.
- (id)cellPrototype
The prototype NSCell
. The prototype NSCell
instance is copied to display items in the matrices of the browser.
NSBrowser.h
Given the column width, returns the content width.
- (CGFloat)columnContentWidthForColumnWidth:(CGFloat)columnWidth
The width of the column. This width is the entire scrolling text view.
The width of the content for the column. This is the width of the matrix in the column.
NSBrowser.h
Returns the column number in which the given matrix is located.
- (NSInteger)columnOfMatrix:(NSMatrix *)matrix
The matrix for which to return the column number.
The index of the column in which the specified matrix appears.
NSBrowser.h
Returns the receiver’s column resizing type.
- (NSBrowserColumnResizingType)columnResizingType
A constant indicating the column resizing type. Possible return values are described in NSBrowserColumnResizingType
. The default is NSBrowserAutoColumnResizing
NSBrowser.h
Returns the name used to automatically save the receiver’s column configuration.
- (NSString *)columnsAutosaveName
The name used to save the column configuration.
NSBrowser.h
Given the content width, returns the column width.
- (CGFloat)columnWidthForColumnContentWidth:(CGFloat)columnContentWidth
The width of the column's content (the width of the the matrix in the column).
The width of the column (the width of the entire scrolling text view).
For example, to guarantee that 16 pixels of your browser cell are always visible, call:
[browser setMinColumnWidth: [browser columnWidthForColumnContentWidth:16]] |
NSBrowser.h
Returns the receiver’s delegate.
- (id)delegate
The receiver's delegate.
NSBrowser.h
Updates the receiver to display all loaded columns.
- (void)displayAllColumns
NSBrowser.h
Updates the receiver to display the given column.
- (void)displayColumn:(NSInteger)column
The index of the column to display.
NSBrowser.h
Responds to (single) mouse clicks in a column of the receiver.
- (void)doClick:(id)sender
NSBrowser.h
Responds to double clicks in a column of the receiver.
- (void)doDoubleClick:(id)sender
NSBrowser.h
Returns the receiver’s double-click action method.
- (SEL)doubleAction
The action method invoked when the user double-clicks on the browser.
NSBrowser.h
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
Rows the user is dragging.
Column with the rows the user is dragging.
Mouse drag event.
Offset for the returned image:
NSZeroPoint
: The image is centered under the pointer.
Image representing the visible cells identified by rowIndexes.
NSBrowser.h
Indicates the types of dragging operations the source object allows on the dragged image’s data.
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)localDestination
Indicates the location of the dragging operation’s destination object: YES
for this application, NO
for another application.
NSDragOperationEvery
when localDestination is YES
.
NSDragOperationNone
when localDestination is NO
.
This method overrides NSDraggingSource
draggingSourceOperationMaskForLocal:
.
Draws the title for the specified column within the given rectangle.
- (void)drawTitleOfColumn:(NSInteger)column inRect:(NSRect)aRect
The index of the column for which to draw the title.
The rectangle within which to draw the title.
NSBrowser.h
Returns the index of the first visible column.
- (NSInteger)firstVisibleColumn
The index of the first visible column.
NSBrowser.h
Returns the rectangle containing the given column.
- (NSRect)frameOfColumn:(NSInteger)column
The index of the column for which to retrieve the frame.
The rectangle containing the specified column.
NSBrowser.h
Returns the rectangle containing the specified column, not including borders.
- (NSRect)frameOfInsideOfColumn:(NSInteger)column
The index of the column for which to retrieve the inside frame.
The rectangle containing the column, not including the column borders.
NSBrowser.h
Returns a Boolean value indicating whether the browser has a horizontal scroller.
- (BOOL)hasHorizontalScroller
YES
if the browser uses an NSScroller
object to scroll horizontally; otherwise NO
.
NSBrowser.h
Returns whether column 0 is loaded.
- (BOOL)isLoaded
YES
if column 0 is loaded; otherwise NO
.
NSBrowser.h
Indicates whether the receiver is opaque.
- (BOOL)isOpaque
YES
when the receiver doesn’t have a title and its background color’s alpha component is 1.0
, NO
otherwise.
This method overrides NSView
isOpaque
.
Returns a Boolean value indicating whether columns display titles.
- (BOOL)isTitled
YES
if the columns in a browser display titles; otherwise NO
.
NSBrowser.h
Returns the index of the last column loaded.
- (NSInteger)lastColumn
The index of the last loaded column.
NSBrowser.h
Returns the index of the last visible column.
- (NSInteger)lastVisibleColumn
The index of the last visible column.
NSBrowser.h
Loads column 0; unloads previously loaded columns.
- (void)loadColumnZero
NSBrowser.h
Loads, if necessary, and returns the NSCell
at the specified row and column location.
- (id)loadedCellAtRow:(NSInteger)row column:(NSInteger)column
The row index of the cell to return.
The column index of the cell to return.
NSBrowser.h
Returns the matrix class used in the receiver’s columns.
- (Class)matrixClass
The class of NSMatrix
used in the browser's columns.
NSBrowser.h
Returns the matrix located in the specified column.
- (NSMatrix *)matrixInColumn:(NSInteger)column
The column index of the matrix to obtain.
The matrix located in the column.
NSBrowser.h
Returns the maximum number of visible columns.
- (NSInteger)maxVisibleColumns
The maximum number of visible columns.
NSBrowser.h
Returns the minimum column width.
- (CGFloat)minColumnWidth
The minimum column width, in pixels.
NSBrowser.h
Provides the names of the files that the receiver promises to create at a specified location.
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
Result of sending browser:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:inColumn:
to the delegate.
Implementation of NSDraggingSource
namesOfPromisedFilesDroppedAtDestination:
.
Returns the number of columns visible.
- (NSInteger)numberOfVisibleColumns
The number of visible columns.
NSBrowser.h
Returns a string representing the receiver’s current path.
- (NSString *)path
The path representing the current selection. The components of this path are separated with the string returned by pathSeparator
.
Invoking this method is equivalent to invoking pathToColumn:
for all columns.
NSBrowser.h
Returns the path separator.
- (NSString *)pathSeparator
The path separator. The default is “/”.
NSBrowser.h
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
The index of the column at which the path stops.
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
.
NSBrowser.h
Returns a Boolean value indicating if the browser is set to resize all columns simultaneously rather than resizing a single column at a time.
- (BOOL)prefersAllColumnUserResizing
YES
if the browser is set to resize all columns simultaneously; otherwise NO
. The default is 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.
NSBrowser.h
Reloads the given column if it exists and sets it to be the last column.
- (void)reloadColumn:(NSInteger)column
The index of the column to reload.
NSBrowser.h
Returns a Boolean value indicating whether the browser reuses NSMatrix
objects after their columns are unloaded.
- (BOOL)reusesColumns
YES
if NSMatrix
objects aren't freed when their columns are unloaded; otherwise NO
.
NSBrowser.h
Scrolls columns left by the specified number of columns.
- (void)scrollColumnsLeftBy:(NSInteger)shiftAmount
The number of columns by which to scroll the browser.
NSBrowser.h
Scrolls columns right by the specified number of columns.
- (void)scrollColumnsRightBy:(NSInteger)shiftAmount
The number of columns by which to scroll the browser.
NSBrowser.h
Scrolls to make the specified column visible.
- (void)scrollColumnToVisible:(NSInteger)column
The index of the column to scroll to.
NSBrowser.h
Scrolls columns left or right based on an NSScroller
.
- (void)scrollViaScroller:(NSScroller *)sender
The NSScroller
object that determines the scrolling of the browser columns.
NSBrowser.h
Selects all NSCell
objects in the last column of the receiver.
- (void)selectAll:(id)sender
NSBrowser.h
Returns the last (rightmost and lowest) selected NSCell
.
- (id)selectedCell
The selected cell.
NSBrowser.h
Returns the last (lowest) NSCell
selected in the given column.
- (id)selectedCellInColumn:(NSInteger)column
The column for which to return the last selected cell.
The last (or lowest) selected cell.
NSBrowser.h
Returns all cells selected in the rightmost column.
- (NSArray *)selectedCells
An array of NSCell
objects representing the selected cells in the rightmost browser column.
NSBrowser.h
Returns the index of the last column with a selected item.
- (NSInteger)selectedColumn
The index of the last column with a selected item.
NSBrowser.h
Returns the row index of the selected cell in the specified column.
- (NSInteger)selectedRowInColumn:(NSInteger)column
The column index specifying the column for which to return the selected row.
The row index of the selected cell in the specified column.
NSBrowser.h
Provides the indexes of the selected rows in a given column of the receiver.
- (NSIndexSet *)selectedRowIndexesInColumn:(NSInteger)columnIndex
Column whose selected rows are provided.
Rows selected in column columnIndex.
NSBrowser.h
Selects the cell at the specified row and column index.
- (void)selectRow:(NSInteger)row inColumn:(NSInteger)column
The row index of the cell to select.
The column index of the cell to select.
NSBrowser.h
Specifies the selected rows in a given column of the receiver.
- (void)selectRowIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)columnIndex
Rows to be selected in column columnIndex.
Column in which to select rows rowIndexes.
NSBrowser.h
Sends the action message to the target.
- (BOOL)sendAction
YES
if successful, NO
if no target for the message could be found.
NSBrowser.h
Returns a Boolean value indicating whether pressing an arrow key causes an action message to be sent.
- (BOOL)sendsActionOnArrowKeys
NO
if pressing an arrow key only scrolls the receiver, YES
if it also sends the action message specified by setAction:
.
NSBrowser.h
Returns a Boolean value indicating whether columns are separated by bezeled borders.
- (BOOL)separatesColumns
YES
if the browser's columns are separated by bezeled borders; otherwise NO
.
NSBrowser.h
Specifies whether the browser allows navigation using the arrow keys.
- (void)setAcceptsArrowKeys:(BOOL)flag
YES
to enable the use of the arrow keys for navigating within and between browsers; otherwise NO
.
NSBrowser.h
Sets whether the user can select branch items.
- (void)setAllowsBranchSelection:(BOOL)flag
YES
if the user can select branch items when multiple selection is enabled; otherwise NO
.
NSBrowser.h
Sets whether there can be nothing selected.
- (void)setAllowsEmptySelection:(BOOL)flag
YES
if the browser allows an empty selection; otherwise NO
.
NSBrowser.h
Sets whether the user can select multiple items.
- (void)setAllowsMultipleSelection:(BOOL)flag
YES
if the user can select multiple items at once; otherwise NO
.
NSBrowser.h
Specifies whether the receiver allows keystroke-based selection.
- (void)setAllowsTypeSelect:(BOOL)allowsTypeSelection
NSBrowser.h
Specifies the receiver’s background color.
- (void)setBackgroundColor:(NSColor *)backgroundColor
[NSColor clearColor]
specifies a transparent background.
NSBrowser.h
Sets the class of NSCell
used by the matrices in the columns of the receiver.
- (void)setCellClass:(Class)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:
.
NSBrowser.h
Sets the NSCell
instance copied to display items in the matrices in the columns of the receiver.
- (void)setCellPrototype:(NSCell *)aCell
The prototype NSCell
instance.
NSBrowser.h
Sets the receiver’s column resizing type.
- (void)setColumnResizingType:(NSBrowserColumnResizingType)columnResizingType
A constant specifying the column resizing type. Possible values are described in NSBrowserColumnResizingType
. The default is NSBrowserAutoColumnResizing
. This setting is persistent.
NSBrowser.h
Sets the name used to automatically save the receiver’s column configuration.
- (void)setColumnsAutosaveName:(NSString *)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.
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.
NSBrowser.h
Sets the receiver’s delegate.
- (void)setDelegate:(id)anObject
The object to set at the receiver's delegate.
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:
.
NSBrowser.h
Sets the receiver’s double-click action.
- (void)setDoubleAction:(SEL)aSelector
The action method to invoke when the receiver is double-clicked.
For the method to have any effect, the receiver’s action and target must be set to the class in which the selector is declared. See Action Messages for additional information on action messages.
NSBrowser.h
Specifies the drag-operation mask for dragging operations with local or external destinations.
- (void)setDraggingSourceOperationMask:(NSDragOperation)dragOperationMask forLocal:(BOOL)localDestination
Dragging operation mask to use for either local or external drag operations, as specified by localDestination.
Indicates the location of the dragging operation’s destination object:
NSBrowser.h
Sets whether an NSScroller
is used to scroll horizontally.
- (void)setHasHorizontalScroller:(BOOL)flag
YES
if the browser uses an NSScroller
object to scroll horizontally; otherwise NO
.
NSBrowser.h
Sets the last column.
- (void)setLastColumn:(NSInteger)column
The index of the last column.
NSBrowser.h
Sets the matrix class used in the receiver’s columns.
- (void)setMatrixClass:(Class)factoryId
The matrix class (NSMatrix
or an NSMatrix
subclass) used in the browser's columns.
NSBrowser.h
Sets the maximum number of columns displayed.
- (void)setMaxVisibleColumns:(NSInteger)columnCount
The maximum number of visible columns.
NSBrowser.h
Sets the minimum column width.t
- (void)setMinColumnWidth:(CGFloat)columnWidth
The minimum column width, specified in pixels.
NSBrowser.h
Sets the path displayed by the receiver.
- (BOOL)setPath:(NSString *)path
The path to display. If path is prefixed by the path separator, the path is absolute, containing the full path from the receiver’s first column. Otherwise, the path is relative, extending the receiver’s current path starting at the last column.
YES
if the given path is valid; otherwise, NO
.
While parsing path, the receiver 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 receiver’s hierarchy, the method returns YES
.
NSBrowser.h
Sets the path separator.
- (void)setPathSeparator:(NSString *)newString
The new path separator.
NSBrowser.h
Specifies whether the browser resizes all columns simultaneously rather than resizing a single column at a time.
- (void)setPrefersAllColumnUserResizing:(BOOL)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.
NSBrowser.h
Specifies whether NSMatrix
objects are reused.
- (void)setReusesColumns:(BOOL)flag
YES
to prevent NSMatrix
objects from being freed when their columns are unloaded, so they can be reused; otherwise NO
.
NSBrowser.h
Sets whether pressing an arrow key causes the action message to be sent.
- (void)setSendsActionOnArrowKeys:(BOOL)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.
NSBrowser.h
Sets whether to separate columns with bezeled borders.
- (void)setSeparatesColumns:(BOOL)flag
YES
if the browser's collumns should be separated by bezeled borders; otherwise NO
. This value is ignored if isTitled
does not return NO
NSBrowser.h
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
YES
if the title of a column should be set to the string value of the selected NSCell
in the previous column; otherwise NO
.
NSBrowser.h
Sets the title of the given column.
- (void)setTitle:(NSString *)aString ofColumn:(NSInteger)column
The title of the column.
The index of the column whose title should be set.
NSBrowser.h
Sets whether columns display titles.
- (void)setTitled:(BOOL)flag
YES
if the columns in a browser display titles; otherwise NO
.
NSBrowser.h
Sets the width of the specified column.
- (void)setWidth:(CGFloat)columnWidth ofColumn:(NSInteger)columnIndex
The new width of the specified column.
The index of the column for which to set the width.
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 receiver can autosave the new column configuration.
NSBrowser.h
Returns a Boolean value indicating whether a column takes its title from the selected cell in the previous column.
- (BOOL)takesTitleFromPreviousColumn
YES
if the title of a column is set to the string value of the selected NSCell
in the previous column; otherwise NO
.
NSBrowser.h
Adjusts the various subviews of the receiver—scrollers, columns, titles, and so on—without redrawing.
- (void)tile
Your code shouldn’t send this message. It’s invoked any time the appearance of the receiver changes.
NSBrowser.h
Returns the bounds of the title frame for the specified column.
- (NSRect)titleFrameOfColumn:(NSInteger)column
The index of the column for which to return the title frame.
The rectangle specifying the bounds of the column's title frame.
NSBrowser.h
Returns the height of column titles.
- (CGFloat)titleHeight
The height of the column titles for the browser.
NSBrowser.h
Returns the title displayed for the given column.
- (NSString *)titleOfColumn:(NSInteger)column
The index of the column for which to get the title.
The title of the specified column.
NSBrowser.h
Updates the horizontal scroller to reflect column positions.
- (void)updateScroller
NSBrowser.h
Invokes the delegate method browser:isColumnValid:
for visible columns.
- (void)validateVisibleColumns
NSBrowser.h
Returns the width of the specified column.
- (CGFloat)widthOfColumn:(NSInteger)column
The index of the column for which to retrieve the width.
The width of the column.
NSBrowser.h
Sent to the delegate during a dragging session to determine whether to accept the drop. Required for a browser to be a drag destination.
- (BOOL)browser:(NSBrowser *)sender acceptDrop:(id <NSDraggingInfo>)dragInfo atRow:(NSInteger)dropReferenceRowIndex column:(NSInteger)dropColumnIndex dropOperation:(NSBrowserDropOperation)dropRowRelativeLocation
Browser querying its delegate.
Drag session information.
The drop row.
The drop column.
Drop location relative to dropRowIndex.
YES
to accept the drop, NO
to decline it.
Sent after browser:validateDrop:proposedRow:column:dropOperation:
allows the drop.
The delegate should incorporate the pasteboard data from the dragging session (dragInfo.draggingPasteboard
)
NSBrowser.h
Sent to the delegate to determine whether the browser can attempt to initiate a drag of the given rows for the given event.
- (BOOL)browser:(NSBrowser *)sender canDragRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)columnIndex withEvent:(NSEvent *)dragEvent
Browser querying its delegate.
Rows the user is dragging
Column containing the rows the user is dragging.
Mouse-drag event.
YES
to allow the drag operation, NO
to disallow it.
NSBrowser.h
Creates a row in the given matrix for each row of data to be displayed in the specified column of the browser.
- (void)browser:(NSBrowser *)sender createRowsForColumn:(NSInteger)column inMatrix:(NSMatrix *)matrix
The browser.
The index of the column for which to create the rows.
The NSMatrix
object in which to create the rows.
Either this method or browser:numberOfRowsInColumn:
must be implemented, but not both (or an NSBrowserIllegalDelegateException
will be raised).
NSBrowser.h
Sent to the delegate to obtain an image to represent dragged rows during a drag operation on a browser.
- (NSImage *)browser:(NSBrowser *)sender draggingImageForRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)columnIndex withEvent:(NSEvent *)dragEvent offset:(NSPointPointer)inout_dragImageOffset
Browser querying its delegate.
Rows the user is dragging.
Column with the rows the user is dragging.
Mouse drag event.
Offset for the returned image:
NSZeroPoint
: Centers the image under the pointer.
Image representing the visible rows identified by rowIndexes.
NSBrowser.h
Returns whether the contents of the specified column are valid.
- (BOOL)browser:(NSBrowser *)sender isColumnValid:(NSInteger)column
The browser for which to validate the contents.
The index of the column to validate.
YES
if the column's contents are valid; otherwise NO
. If NO
is returned, sender reloads the column.
This method is invoked in response to validateVisibleColumns
being sent to sender.
NSBrowser.h
Implements file-promise drag operations.
- (NSArray *)browser:(NSBrowser *)sender namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropURL forDraggedRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)columnIndex
Browser querying its delegate.
Drop filesystem location.
Rows the user is dropping.
Column with the rows the user is dropping.
Filenames (not pathnames) for the actual files represented by the rows the user is dropping.
Note: File-promise drag operation support requires adding NSFilesPromisePboardType
to the pasteboard in browser:writeRowsWithIndexes:inColumn:toPasteboard:
-browser:writeRowWithIndexes:inColumn:toPasteboard:
NSBrowser.h
Sent to the delegate to customize a browser’s keyboard-based selection (type select) behavior.
- (NSInteger)browser:(NSBrowser *)sender nextTypeSelectMatchFromRow:(NSInteger)startRowIndex toRow:(NSInteger)endRowIndex inColumn:(NSInteger)columnIndex forString:(NSString *)searchString
Browser querying its delegate.
Beginning of row-set to search.
End of row-set to to search. Can be less than startRowIndex when the search wraps to the beginning.
Column with the rows being searched.
Keyboard-based selection string. It’s nil
when no keyboard-based selection has begun.
Index—between startRowIndex
and endRowIndex - 1
, inclusive—of the first row that matches searchString.
-1
indicates that there’s no match.
– browser:shouldTypeSelectForEvent:withCurrentSearchString:
– browser:typeSelectStringForRow:inColumn:
NSBrowser.h
Returns the number of rows of data in the specified column.
- (NSInteger)browser:(NSBrowser *)sender numberOfRowsInColumn:(NSInteger)column
The browser.
The index of the column for which to return the number of rows.
The number of rows of data in the specified column.
Either this method or browser:createRowsForColumn:inMatrix:
must be implemented, but not both.
NSBrowser.h
Asks the delegate to select the NSCell
with the given title in the specified column.a
- (BOOL)browser:(NSBrowser *)sender selectCellWithString:(NSString *)title inColumn:(NSInteger)column
The browser.
The title of the cell to select.
The index of the column containing the cell to select.
YES
if the NSCell
was successfully select; otherwise, NO
.
It is the delegate’s responsibility to select the cell, rather than the browser. Invoked in response to setPath:
being received by sender.
NSBrowser.h
Asks the delegate to select the NSCell
at the specified row and column location.
- (BOOL)browser:(NSBrowser *)sender selectRow:(NSInteger)row inColumn:(NSInteger)column
The browser.
The index of the row containing the cell to select.
The index of the column containing the cell to select.
NO
if the NSCell
was not selected; otherwise YES
.
It is the delegate’s responsibility to select the cell, rather than the browser. Invoked in response to selectRow:inColumn:
being received by sender.
NSBrowser.h
Determines whether an expansion tooltip appears for a cell at the given row in the given column.
- (BOOL)browser:(NSBrowser *)sender shouldShowCellExpansionForRow:(NSInteger)rowIndex column:(NSInteger)columnIndex
Browser querying its delegate.
Row requesting an expansion tooltip.
Column with the requesting row.
YES
to allow the cell expansion tooltip, NO
to disallow it.
NSBrowser.h
Used for determining a column’s initial size.
- (CGFloat)browser:(NSBrowser *)browser shouldSizeColumn:(NSInteger)columnIndex forUserResize:(BOOL)forUserResize toWidth:(CGFloat)suggestedWidth
The browser.
The index of the column to size.
As currently implemented, this method is always called with forUserResize set to NO
.
The suggested width for the column.
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 you requested.
Implementation is optional and applies only to browsers with resize type NSBrowserNoColumnResizing
or NSBrowserUserColumnResizing
(see NSBrowserColumnResizingType
). I
NSBrowser.h
Sent to the delegate to determine whether keyboard-based selection (type select) for a given event and search string should proceed.
- (BOOL)browser:(NSBrowser *)sender shouldTypeSelectForEvent:(NSEvent *)keyEvent withCurrentSearchString:(NSString *)searchString
Browser querying its delegate.
Keyboard event being processed.
Keyboard-based selection string. It’s nil
when no keyboard-based selection has begun.
YES
to allow the selection, NO
to disallow it.
NSBrowser.h
Returns the ideal width for a column.
- (CGFloat)browser:(NSBrowser *)browser sizeToFitWidthOfColumn:(NSInteger)columnIndex
The browser.
The index of the column to size. If columnIndex is –1, the result is used for a “right-size-all” operation.
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). It is assumed that the implementation may be expensive, so it will be called only when necessary.
Implementation is optional and is for browsers with resize type NSBrowserUserColumnResizing
only.
NSBrowser.h
Asks the delegate for the title to display above the specified column.
- (NSString *)browser:(NSBrowser *)sender titleOfColumn:(NSInteger)column
The browser.
The index of the column for which to return the title.
The title of the specified column.
NSBrowser.h
Sent to the delegate to get the keyboard-based selection (type select) string for a given row and column.
- (NSString *)browser:(NSBrowser *)sender typeSelectStringForRow:(NSInteger)rowIndex inColumn:(NSInteger)columnIndex
Browser querying its delegate.
Row being inquired about.
Column with the row being inquired about.
Keyboard-based selection string for the identified row and column.
Returning the empty string or nil
(for example, when the cell does not contain text) specifies that the [
columnIndex, rowIndex]
cell has no text to search.
If the delegate does not implement this method, all cells with text are searched, and the browser determines the keyboard-based selection text by sending stringValue
to the cell specified by columnIndex and rowIndex.
NSBrowser.h
Sent to the delegate during a dragging session to determine whether to accept a drop, and to obtain the drop location. Required for a browser to be a drag destination.
- (NSDragOperation)browser:(NSBrowser *)sender validateDrop:(id <NSDraggingInfo>)dragInfo proposedRow:(NSInteger *)inout_dropReferenceRowIndex column:(NSInteger *)inout_dropColumnIndex dropOperation:(NSBrowserDropOperation *) inout_dropRowRelativeLocation
Browser querying its delegate.
Drag session information.
Together with inout_dropRowRelativeLocation specifies the drop location.
On input, the proposed drop reference row.
On output, the drop reference row.
Column on which the dragged rows are being dropped.
On input, the proposed drop column.
On output, the drop column.
Drop location, within the rows identified in rowIndexes, of the drag operation.
On input, the proposed drop location.
On output, the drop location.
Drag operation the data source is to perform. Must not be NSDragOperationNone
for sender to accept the drop.
The browser proposes a drop column, row, and row-relative location for the drop based on the pointer position, as shown in this table:
Drop relative location | Description |
---|---|
| Dragging location (dragInfo |
| Dragging location is between two rows. Indicates a drop location above inout_dropReferenceRowIndex and below inout_dropReferenceRowIndex |
These are a few examples of how to specify a drop location:
Reference row index | Row-relative location | |
---|---|---|
On row 2 |
|
|
Between rows 2 and 3 |
|
|
Below the last row |
|
|
All rows |
|
|
NSBrowser.h
Gives the delegate the opportunity to modify the specified cell at the given row and column position before it’s displayed by the NSBrowser
.
- (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell atRow:(NSInteger)row column:(NSInteger)column
The browser.
The cell to be displayed.
The row index of the cell to be displayed.
The column index of the cell to be displayed.
The delegate should set any state necessary for the correct display of the cell.
NSBrowser.h
Determines whether a drag operation can proceed. Required for a browser to be a drag source.
- (BOOL)browser:(NSBrowser *)sender writeRowsWithIndexes:(NSIndexSet *)rowIndexes inColumn:(NSInteger)columnIndex toPasteboard:(NSPasteboard *)pasteboard
Browser querying its delegate.
Rows the user is dragging.
Column with the dragged rows.
Content from the dragged rows.
YES
to allow the dragging operation to proceed (see discussion for further details), NO
to disallow it.
Called after a drag operation has been allowed to start (browser:canDragRowsWithIndexes:inColumn:withEvent:
returns YES
) but before it actually begins.
NSBrowser.h
Used by clients to implement their own column width persistence.
- (void)browserColumnConfigurationDidChange:(NSNotification *)notification
The notification of the configuration change.
Implementation is optional, and used for browsers with resize type NSBrowserUserColumnResizing
only. It is called when the method setWidth:ofColumn:
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.
NSBrowser.h
Notifies the delegate when the NSBrowser
has scrolled.
- (void)browserDidScroll:(NSBrowser *)sender
The browser sending the message.
NSBrowser.h
Notifies the delegate when the NSBrowser
will scroll.
- (void)browserWillScroll:(NSBrowser *)sender
The browser sending the message.
NSBrowser.h
Describe types of browser column resizing.
typedef enum _NSBrowserColumnResizingType { NSBrowserNoColumnResizing = 0, NSBrowserAutoColumnResizing = 1, NSBrowserUserColumnResizing = 2 } NSBrowserColumnResizingType;
NSBrowserNoColumnResizing
Neither NSBrowser
nor the user can change the column width. The developer must explicitly set all column widths.
Available in Mac 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 Mac 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 Mac OS X v10.3 and later.
Declared in NSBrowser.h
.
These constants are used by the setColumnResizingType:
and columnResizingType
methods.
NSBrowser.h
This type is used to to specifying the drop type of a drag-and-drop operation. See browser:validateDrop:proposedRow:column:dropOperation for more information.
enum { NSBrowserDropOn, NSBrowserDropAbove }; typedef NSUInteger NSBrowserDropOperation;
NSBrowser.h
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.
NSBrowser.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-05)