Instance Method


Returns a Boolean indicating whether the collection view can begin dragging the specified items.


optional func collectionView(_ collectionView: NSCollectionView, canDragItemsAt indexes: IndexSet, with event: NSEvent) -> Bool



The collection view containing the items to be dragged.


The indexes of the items to be dragged.


The mouse event that initiated the drag action.

Return Value

true if the collection view can begin the drag operation for the specified items or false if it cannot.


Implement this method when you want selective control over the initiation of drag operations. In your implementation, use the provided information to determine whether the drag operation should occur and return the appropriate return value. For example, you might return false if your interface does not allow the user to drag the specified items.

If you do not implement this method in your delegate object, the collection view assumes a return value of true and begins the drag operation.

See Also

Legacy Collection View Support