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) -> BoolParameters
collectionViewThe collection view
indexPathThe indexpath at the location of the drag
eventThe 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
collectionViewThe collection view that began the drag
indexPathsThe 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
collectionViewThe collection view
sessionThe dragging session
pointThe 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
collectionViewThe collection view
sessionThe drag session
screenPointThe screen point at which the drag ended
operationThe 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
collectionViewThe collection view
sessionThe drag session
pointThe 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) -> NSDragOperationParameters
collectionViewThe collection view
dragInfoThe 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) -> NSDragOperationParameters
collectionViewThe collection view
dragInfoThe 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
collectionViewThe collection view
dragInfoThe 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
collectionViewThe collection view
dragInfoThe drag info
-
Asks the delegate to handle the drop in the collection view
Declaration
Swift
@objc optional func collectionView(_ collectionView: CollectionView, performDragOperation dragInfo: NSDraggingInfo) -> BoolParameters
collectionViewThe collection view (dragging destination) the drag ended in
dragInfoThe drag info
Return Value
True if the drag is completed. False to cancel the drag