Contents

collectionView(_:draggingImageForItemsAt:with:offset:)

Creates and returns a drag image to represent the specified items during a drag.

Declaration

@MainActor optional func collectionView(_ collectionView: NSCollectionView, draggingImageForItemsAt indexes: IndexSet, with event: NSEvent, offset dragImageOffset: NSPointPointer) -> NSImage

Parameters

  • collectionView:

    The collection view making the request.

  • indexes:

    The indexes of the items being dragged.

  • event:

    The mouse-down event that initiated the drag.

  • dragImageOffset:

    An in/out parameter that is initially set to Nszeropoint, which causes the image to be centered under the mouse. The value can be modified to reposition the returned image.

Return Value

The image to use for the dragged items.

Discussion

If the delegate does not implement this method, the collection view uses the image returned by draggingImageForItems(at:with:offset:).

You do not need to implement this method for your collection view to be a drag source.

See Also

Legacy Collection View Support