NSPathControl Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.5 and later. |
| Declared in | NSPathControl.h |
Overview
NSPathControl is a subclass of NSControl that represents a file system path or virtual path.
The NSPathControl class uses NSPathCell to implement its user interface. NSPathControl provides cover methods for most NSPathCell methods—the cover method simply invokes the corresponding cell method. See also NSPathComponentCell, which represents individual components of the path, and two associated protocols: NSPathCellDelegate and NSPathControlDelegate.
NSPathControl has three styles represented by the NSPathStyle enumeration constants NSPathStyleStandard, NSPathStyleNavigationBar, and NSPathStylePopUp. The represented path can be a file system path or any other type of path leading through a sequence of nodes or components, as defined by the programmer.
NSPathControl automatically supports drag and drop, which can be further customized via delegate methods. To accept drag and drop, NSPathControl calls registerForDraggedTypes: with NSFilenamesPboardType and NSURLPboardType. When the URL value in the NSPathControl object changes because of an automatic drag and drop operation or the user selecting a new path via the open panel, the action is sent. On OS X v10.5 the value returned by clickedPathComponentCell is nil, on OS X v10.6 and later, clickedPathComponentCell returns the clicked cell.
Tasks
Setting the Control Style
Setting the Background Color
Managing Path Components
Setting the Double-Click Action
Setting the Path
Setting the Delegate
Setting the Drag Operation Mask
Setting Popup Menu
Instance Methods
backgroundColor
Returns the current background color of the receiver.
Return Value
The background color.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hclickedPathComponentCell
Returns the clicked cell.
Return Value
The component cell that was clicked.
Discussion
The value returned is generally valid only when the action or double action is being sent.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hdelegate
Returns the receiver’s delegate.
Return Value
The receiver’s delegate.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hdoubleAction
Returns the receiver’s double-click action method.
Return Value
The action method invoked when the user double-clicks the receiver.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hmenu
Returns the menu that is used for the path control’s cells.
Return Value
An instance of NSMenu.
Discussion
This method overrides the NSView implementation of menu and forwards the message to the NSPathControlCell.
Availability
- Available in OS X v10.6 and later.
Declared In
NSPathControl.hpathComponentCells
Returns an array of the NSPathComponentCell objects currently being displayed.
Return Value
The array of NSPathComponentCell objects.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPathControl.hpathStyle
Returns the receiver’s path style.
Return Value
The style of the path control.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hsetBackgroundColor:
Sets the receiver’s background color.
Parameters
- color
The color to draw.
Discussion
By default, the background is set to a light blue color for NSPathStyleStandard and nil for the other styles. You can use [NSColor clearColor] to make the background transparent.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hsetDelegate:
Sets the receiver’s delegate.
Parameters
- delegate
The object to set as the receiver’s delegate.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hsetDoubleAction:
Sets the receiver’s double-click action.
Parameters
- action
The action method to invoke when the receiver is double-clicked.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hsetDraggingSourceOperationMask:forLocal:
Configures the default value returned from draggingSourceOperationMaskForLocal:.
Parameters
- mask
The types of drag operations allowed.
- isLocal
If
YES, mask applies when the drag destination object is in the same application as the receiver; ifNO, mask applies when the destination object is outside the receiver’s application.
Discussion
By default, draggingSourceOperationMaskForLocal: returns NSDragOperationEvery when isLocal is YES and NSDragOperationNone when isLocal is NO.
Availability
- Available in OS X v10.5 and later.
Declared In
NSPathControl.hsetMenu:
Sets the menu used for the path control’s cells.
Parameters
- menu
An instance of NSMenu.
Discussion
This method overrides the NSView implementation of setMenu: and forwards the message to the NSPathControlCell.
Availability
- Available in OS X v10.6 and later.
Declared In
NSPathControl.hsetPathComponentCells:
Sets the array of NSPathComponentCell objects currently being displayed.
Parameters
- cells
An array of
NSPathComponentCellobjects.
Discussion
Each item in the array must be an instance of NSPathComponentCell or a subclass thereof. You cannot set this value to nil, but you can set it to an empty array using, for example, [NSArray array].
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hsetPathStyle:
Sets the receiver’s path style.
Parameters
- style
The new path style.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.hsetURL:
Sets the path value displayed by the receiver.
Parameters
- url
The new path value to display.
Discussion
When setting, an array of NSPathComponentCell objects is automatically set based on the path in url. If url is a file URL (returns YES from isFileURL), the images are automatically filled with file icons, if the path exists. The URL value itself is stored in the objectValue property of the cell.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSPathControl.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-12-05)