Instance Method

collectionView(_:canDragItemsAt:with:)

Returns a Boolean indicating whether a drag operation involving the specified items can begin.

Declaration

optional func collectionView(_ collectionView: NSCollectionView, canDragItemsAt indexPaths: Set<IndexPath>, with event: NSEvent) -> Bool

Parameters

collectionView

The collection view making the request.

indexPaths

The index paths of the items about to be dragged.

event

The mouse-down event that began the drag operation.

Return Value

true if the drag operation can begin or false if it cannot.

Discussion

If you do not implement this method and your collection view has only one section, the collection view calls the legacy collectionView(_:canDragItemsAt:with:) method. If you do not implement either method, the collection view assumes a return value of true.

See Also

Drag and Drop Support

func collectionView(NSCollectionView, pasteboardWriterForItemAt: IndexPath) -> NSPasteboardWriting?

Provides the pasteboard writer for the item at the specified index path.

func collectionView(NSCollectionView, writeItemsAt: Set<IndexPath>, to: NSPasteboard) -> Bool

Places the data for the drag operation on the pasteboard.

Deprecated
func collectionView(NSCollectionView, namesOfPromisedFilesDroppedAtDestination: URL, forDraggedItemsAt: Set<IndexPath>) -> [String]

Returns the names of the promised files that you created for a drag operation.

Deprecated
func collectionView(NSCollectionView, updateDraggingItemsForDrag: NSDraggingInfo)

Asks your delegate to update the dragging items during a drag operation.