CollectionViewDragDelegate

@objc
public protocol CollectionViewDragDelegate : CollectionViewDelegate

The CollectionViewDragDelegate forwards system drag functions to the delegate in the context of a Collection View.

  • Asks the delegate if a dragging session should be started

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, shouldBeginDraggingAt indexPath: IndexPath, with event: NSEvent) -> Bool

    Parameters

    collectionView

    The collection view

    indexPath

    The indexpath at the location of the drag

    event

    The mouse event

    Return Value

    True if a dragging session should begin

  • Asks the delegate to validate the selected items for drag.

    This provides an opputunity to exclude some of the selected index paths from being dragged

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, validateIndexPathsForDrag indexPaths: [IndexPath]) -> [IndexPath]

    Parameters

    collectionView

    The collection view that began the drag

    indexPaths

    The selected index paths when the drag began

    Return Value

    The index paths that should be included in the drag.

  • Notifies the delegate that a dragging session will begin

    If collectionView(:shouldBeginDraggingAt:with) returns false this will not be called

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, draggingSession session: NSDraggingSession, willBeginAt point: NSPoint)

    Parameters

    collectionView

    The collection view

    session

    The dragging session

    point

    The location of the drag

  • Notifies the delegate that a dragging session ended

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, draggingSession session: NSDraggingSession, didEndAt screenPoint: NSPoint, with operation: NSDragOperation, draggedIndexPaths: [IndexPath])

    Parameters

    collectionView

    The collection view

    session

    The drag session

    screenPoint

    The screen point at which the drag ended

    operation

    The dragging operation at the time the drag ended

  • Notifies the delegate that a dragging session moved

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, draggingSession session: NSDraggingSession, didMoveTo point: NSPoint)

    Parameters

    collectionView

    The collection view

    session

    The drag session

    point

    The location of the drag

  • Asks the delegate for an operation for the drag at its current state when it enters the collection view

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, dragEntered dragInfo: NSDraggingInfo) -> NSDragOperation

    Parameters

    collectionView

    The collection view

    dragInfo

    The drag info

    Return Value

    A drag operation indicating how the drag should be handled

  • Asks the delegate for an operation for the drag at its current state as it updates

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, dragUpdated dragInfo: NSDraggingInfo) -> NSDragOperation

    Parameters

    collectionView

    The collection view

    dragInfo

    The drag info

    Return Value

    A drag operation indicating how the drag should be handled

  • Notifies the delegate that a drag exited the collection view as a dragging destination

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, dragExited dragInfo: NSDraggingInfo?)

    Parameters

    collectionView

    The collection view

    dragInfo

    The drag info

  • Notifies the delegate that a drag ended in the collection view as a dragging destination

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, dragEnded dragInfo: NSDraggingInfo?)

    Parameters

    collectionView

    The collection view

    dragInfo

    The drag info

  • Asks the delegate to handle the drop in the collection view

    Declaration

    Swift

    @objc
    optional func collectionView(_ collectionView: CollectionView, performDragOperation dragInfo: NSDraggingInfo) -> Bool

    Parameters

    collectionView

    The collection view (dragging destination) the drag ended in

    dragInfo

    The drag info

    Return Value

    True if the drag is completed. False to cancel the drag