collectionView(_:writeItemsAt:to:)
Invoked after it has been determined that a drag should begin, but before the drag has been started.
Declaration
optional func collectionView(_ collectionView: NSCollectionView, writeItemsAt indexes: IndexSet, to pasteboard: NSPasteboard) -> BoolParameters
- collectionView:
The collection view that send the message.
- indexes:
The indexes of the items to write to the pasteboard.
- pasteboard:
The pasteboard containing the content from the dragged items.
Return Value
Discussion
To start the drag, you must first declare the pasteboard types that are supported by sending pasteboard a declareTypes(_:owner:) method. You then place the data for the items at the specified indexes on pasteboard, and return true from the method.
The drag image and other drag related information will be set up and provided by the view once this call returns true.
You need to implement this method for your collection view to be a drag source.
See Also
Legacy Collection View Support
collectionView(_:canDragItemsAt:with:)collectionView(_:pasteboardWriterForItemAt:)collectionView(_:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAt:)collectionView(_:draggingImageForItemsAt:with:offset:)collectionView(_:draggingSession:willBeginAt:forItemsAt:)collectionView(_:validateDrop:proposedIndex:dropOperation:)collectionView(_:acceptDrop:index:dropOperation:)