The user interface of a path control object.
- macOS 10.5+
NSPath maintains a collection of
NSPath objects that represent a particular path to be displayed to the user.
The path shown can be set with the
clicked method. Doing so removes all displayed
NSPath objects and automatically fills the control with
NSPath objects set to have the appropriate icons, display titles, and
NSURL values for the particular path component they represent. Alternatively, you can fill the control manually by setting the cell array or directly modifying existing cells.
Both an action and double-click action can be set for the path control. To find out what path component cell was clicked in the action, you can read the value of
clicked. When the style is set to
NSPath, the action is still sent, and the
clicked value for the represented menu item is correctly set. The
clicked value is valid only when the action is being sent. It is also valid when the keyboard is used to invoke the action.
Automatic animated expansion of partially hidden
NSPath objects happens if you correctly call
mouse for each
NSPath in the
NSPath object. This is not required if the
path is set to
NSPath, or if you wish to not have the animation.
NSPath supports several path display styles.
NSPath has a light blue background with arrows indicating the path.
NSPath has more defined arrows (chevrons) and looks a little like a segmented button.
NSPath looks and works like an
NSPop object to display the full path, or, if the cell is editable, select a new path.
If the cell’s
editable method returns
YES (the default), you can drag and drop into the cell to change the value. You can constrain what can be dropped using UTIs (Uniform Type Identifiers) with
allowed or the appropriate delegate methods on
If the cell’s
selectable method returns
YES (the default), the cell's contents can automatically be dragged out. The proper UTI, filename, and URL are placed on the pasteboard. You can further control or limit this by using the appropriate delegate methods on
If the cell is editable and has the path style set to
NSPath, an additional item in the pop-up menu allows selecting another location. By default, an
NSOpen object is configured based on the allowed types. The
NSOpen object can be customized with a delegate method.