Mac Developer Library

Developer

AppKit Framework Reference NSPathControl Class Reference

Options
Deployment Target:

On This Page
Language:

NSPathControl

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.

  • The receiver’s background color.

    Declaration

    Swift

    @NSCopying var backgroundColor: NSColor?

    Objective-C

    @property(copy) NSColor *backgroundColor

    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.

  • The receiver’s double-click action method.

    Declaration

    Swift

    var doubleAction: Selector

    Objective-C

    @property SEL doubleAction

    Availability

    Available in OS X v10.5 and later.

  • URL URL Property

    The path value displayed by the receiver.

    Declaration

    Swift

    @NSCopying var URL: NSURL?

    Objective-C

    @property(copy) NSURL *URL

    Discussion

    When setting, an array of NSPathComponentCell objects is automatically set based on the path in url. If url is a file URL (returns YEStrue 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.

  • Configures the default value returned from draggingSourceOperationMaskForLocal:.

    Declaration

    Swift

    func setDraggingSourceOperationMask(_ mask: NSDragOperation, forLocal isLocal: Bool)

    Objective-C

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

    Parameters

    mask

    The types of drag operations allowed.

    isLocal

    If YEStrue, mask applies when the drag destination object is in the same application as the receiver; if NOfalse, mask applies when the destination object is outside the receiver’s application.

    Discussion

    By default, draggingSourceOperationMaskForLocal: returns NSDragOperationEvery when isLocal is YEStrue and NSDragOperationNone when isLocal is NOfalse.

    Availability

    Available in OS X v10.5 and later.

  • menu menu Property

    The menu that is used for the path control’s cells.

    Declaration

    Swift

    var menu: NSMenu?

    Objective-C

    @property(strong) NSMenu *menu

    Discussion

    This property overrides the NSView implementation of menu and forwards the message to the NSPathControlCell.

    Availability

    Available in OS X v10.6 and later.