Mac Developer Library

Developer

AppKit Framework Reference NSPathControlDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSPathControlDelegate

The NSPathControlDelegate optional protocol is implemented by the delegate of an NSPathControl object to support dragging to and from the control.

Inheritance


Not Applicable

Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.5 and later.
  • Implement this method to enable dragging from the control.

    Declaration

    Swift

    optional func pathControl(_ pathControl: NSPathControl, shouldDragPathComponentCell pathComponentCell: NSPathComponentCell, withPasteboard pasteboard: NSPasteboard) -> Bool

    Objective-C

    - (BOOL)pathControl:(NSPathControl *)pathControl shouldDragPathComponentCell:(NSPathComponentCell *)pathComponentCell withPasteboard:(NSPasteboard *)pasteboard

    Parameters

    pathControl

    The path control that sent the message.

    pathComponentCell

    The path component cell from which the drag is beginning.

    pasteboard

    The pasteboard.

    Discussion

    This method is called when a drag is about to begin. You can refuse to allow the drag to happen by returning NOfalse and allow it by returning YEStrue. By default, the pasteboard automatically has the following types on it: NSStringPboardType, NSURLPboardType (if there is a URL value for the cell being dragged), and NSFilenamesPboardType (if the URL value returns YEStrue from -isFileURL). You can customize the types placed on the pasteboard at this time, if desired. Implementation of this method is optional.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Implement this method to enable dragging onto the control.

    Declaration

    Swift

    optional func pathControl(_ pathControl: NSPathControl, validateDrop info: NSDraggingInfo) -> NSDragOperation

    Objective-C

    - (NSDragOperation)pathControl:(NSPathControl *)pathControl validateDrop:(id<NSDraggingInfo>)info

    Parameters

    pathControl

    The path control that sent the message.

    info

    An object containing details about this dragging operation.

    Discussion

    This method is called when something is dragged over the control. Return NSDragOperationNone to refuse the drop, or return anything else to accept it.

    If not implemented, and the control's cell is editable, the drop is accepted if it contains an NSURLPboardType or NSFilenamesPboardType that conforms to the cell’s allowed types. Implementation of this method is optional.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Implement this method to accept previously validated contents dropped onto the control.

    Declaration

    Swift

    optional func pathControl(_ pathControl: NSPathControl, acceptDrop info: NSDraggingInfo) -> Bool

    Objective-C

    - (BOOL)pathControl:(NSPathControl *)pathControl acceptDrop:(id<NSDraggingInfo>)info

    Parameters

    pathControl

    The path control that sent the message.

    info

    An object containing details about this dragging operation.

    Discussion

    In order to accept the dropped contents previously accepted from pathControl:validateDrop:, you must implement this method. This method is called from performDragOperation:. You should change the URL value based on the dragged information.

    If not implemented, and the control's cell is editable, the drop is accepted if it contains an NSURLPboardType or NSFilenamesPboardType that conforms to the cell’s allowed types. The cell's URL value is automatically changed, and the action is invoked. Implementation of this method is optional.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Implement this method to customize the Open panel shown by a pop-up–style path.

    Declaration

    Swift

    optional func pathControl(_ pathControl: NSPathControl, willDisplayOpenPanel openPanel: NSOpenPanel)

    Objective-C

    - (void)pathControl:(NSPathControl *)pathControl willDisplayOpenPanel:(NSOpenPanel *)openPanel

    Parameters

    pathControl

    The path control displaying the Open panel.

    openPanel

    The Open panel to be displayed.

    Discussion

    This method is called before the Open panel is shown but after its allowed file types are set to the cell's allowed types. At this time, you can further customize the Open panel as required. This method is called only when the style is set to NSPathStylePopUp. Implementation of this method is optional.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Implement this method to customize the menu of a pop-up–style path.

    Declaration

    Swift

    optional func pathControl(_ pathControl: NSPathControl, willPopUpMenu menu: NSMenu)

    Objective-C

    - (void)pathControl:(NSPathControl *)pathControl willPopUpMenu:(NSMenu *)menu

    Parameters

    pathControl

    The path control displaying the pop-up menu.

    menu

    The pop-up menu to be displayed.

    Discussion

    This method is called before the pop-up menu is shown. At this time, you can further customize the menu as required, adding and removing items. This method is called only when the style is set to NSPathStylePopUp. Implementation of this method is optional.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.