Next Page > Hide TOC

NSPathControl Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in Mac OS X v10.5 and later.
Declared in
NSPathControl.h
Related sample code

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, but the value returned by clickedPathComponentCell is nil.

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

Instance Methods

backgroundColor

Returns the current background color of the receiver.

- (NSColor *)backgroundColor

Return Value

The background color.

Availability
See Also
Declared In
NSPathControl.h

clickedPathComponentCell

Returns the clicked cell, or nil, if no cell was clicked.

- (NSPathComponentCell *)clickedPathComponentCell

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

delegate

Returns the receiver’s delegate.

- (id)delegate

Return Value

The receiver’s delegate.

Availability
See Also
Declared In
NSPathControl.h

doubleAction

Returns the receiver’s double-click action method.

- (SEL)doubleAction

Return Value

The action method invoked when the user double-clicks the receiver.

Availability
See Also
Declared In
NSPathControl.h

pathComponentCells

Returns an array of the NSPathComponentCell objects currently being displayed.

- (NSArray *)pathComponentCells

Return Value

The array of NSPathComponentCell objects.

Availability
See Also
Declared In
NSPathControl.h

pathStyle

Returns the receiver’s path style.

- (NSPathStyle)pathStyle

Return Value

The style of the path control.

Availability
See Also
Declared In
NSPathControl.h

setBackgroundColor:

Sets the receiver’s background color.

- (void)setBackgroundColor:(NSColor *)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
See Also
Declared In
NSPathControl.h

setDelegate:

Sets the receiver’s delegate.

- (void)setDelegate:(id)delegate

Parameters
delegate

The object to set as the receiver’s delegate.

Availability
See Also
Declared In
NSPathControl.h

setDoubleAction:

Sets the receiver’s double-click action.

- (void)setDoubleAction:(SEL)action

Parameters
action

The action method to invoke when the receiver is double-clicked.

Availability
See Also
Declared In
NSPathControl.h

setDraggingSourceOperationMask:forLocal:

Configures the default value returned from draggingSourceOperationMaskForLocal:.

- (void)setDraggingSourceOperationMask:(NSDragOperation)mask forLocal:(BOOL)isLocal

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; if NO, 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
Declared In
NSPathControl.h

setPathComponentCells:

Sets the array of NSPathComponentCell objects currently being displayed.

- (void)setPathComponentCells:(NSArray *)cells

Parameters
cells

An array of NSPathComponentCell objects.

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

setPathStyle:

Sets the receiver’s path style.

- (void)setPathStyle:(NSPathStyle)style

Parameters
style

The new path style.

Availability
See Also
Declared In
NSPathControl.h

setURL:

Sets the path value displayed by the receiver.

- (void)setURL:(NSURL *)url

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

URL

Returns the path value displayed by the receiver.

- (NSURL *)URL

Return Value

The path value.

Availability
See Also
Declared In
NSPathControl.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-11)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.