collectionView(_:acceptDrop:index:dropOperation:)
Invoked when the mouse is released over a collection view that previously allowed a drop.
Declaration
@MainActor optional func collectionView(_ collectionView: NSCollectionView, acceptDrop draggingInfo: any NSDraggingInfo, index: Int, dropOperation: NSCollectionView.DropOperation) -> BoolParameters
- collectionView:
The collection view that send the message.
- draggingInfo:
An object that contains more information about this dragging operation.
- index:
The index of the proposed drop item.
- dropOperation:
The type of dragging operation.
Return Value
true if the drop operation should be accepted, otherwise false.
Discussion
This method is called when the mouse is released over a collection view that previously decided to allow a drop via the collectionView(_:validateDrop:proposedIndex:dropOperation:) method. At this time, the delegate should incorporate the data from the dragging pasteboard and update the collection view’s contents.
You must implement this method for your collection view to be a drag destination
See Also
Legacy Collection View Support
collectionView(_:canDragItemsAt:with:)collectionView(_:pasteboardWriterForItemAt:)collectionView(_:writeItemsAt:to:)collectionView(_:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAt:)collectionView(_:draggingImageForItemsAt:with:offset:)collectionView(_:draggingSession:willBeginAt:forItemsAt:)collectionView(_:validateDrop:proposedIndex:dropOperation:)