Instance Method

collectionView:draggingImageForItemsAtIndexPaths:withEvent:offset:

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

Declaration

- (NSImage *)collectionView:(NSCollectionView *)collectionView draggingImageForItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths withEvent:(NSEvent *)event offset:(NSPointPointer)dragImageOffset;

Parameters

collectionView

The collection view making the request.

indexPaths

The index paths of the items being dragged.

event

The mouse-down event that began the drag operation. You can use the mouse location when determining what value to return in the dragImageOffset parameter.

dragImageOffset

The offset value to use when positioning the image. On input, the point is NSZeroPoint, which centers the returned image under the mouse. Your method can return a different point that repositions the drag image by the specified offset values.

Return Value

The image to use for the dragged items.

Discussion

Your implementation of this method should create an appropriate image to use during the drag operation. The collection view places the center of your image at the current mouse location. Update the value in the dragImageOffset parameter to shift the position of your image by the specified amount.

If you do not implement this method, the collection view uses the drag image returned by the draggingImageForItemsAtIndexPaths:withEvent:offset: method instead.

See Also

Drag and Drop Support

- collectionView:canDragItemsAtIndexPaths:withEvent:

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

- collectionView:pasteboardWriterForItemAtIndexPath:

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

- collectionView:writeItemsAtIndexPaths:toPasteboard:

Places the data for the drag operation on the pasteboard.

Deprecated
- collectionView:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAtIndexPaths:

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

Deprecated
- collectionView:draggingSession:willBeginAtPoint:forItemsAtIndexPaths:

Notifies your delegate that a drag session is about to begin.

- collectionView:draggingSession:endedAtPoint:dragOperation:

Notifies your delegate that a drag session ended.

- collectionView:updateDraggingItemsForDrag:

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

- collectionView:validateDrop:proposedIndexPath:dropOperation:

Validates whether a drop operation is possible at the specified location.

- collectionView:acceptDrop:indexPath:dropOperation:

Incorporates the dropped content into the collection view.