Instance Method

collectionView:writeItemsAtIndexes:toPasteboard:

Invoked after it has been determined that a drag should begin, but before the drag has been started.

Declaration

- (BOOL)collectionView:(NSCollectionView *)collectionView writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pasteboard;

Parameters

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

YES to begin the drag, otherwise NO.

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 YES from the method.

The drag image and other drag related information will be set up and provided by the view once this call returns YES.

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

See Also

Legacy Collection View Support

- collectionView:canDragItemsAtIndexes:withEvent:

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

- collectionView:pasteboardWriterForItemAtIndex:

Provides the pasteboard writer for the item at the specified index

- collectionView:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAtIndexes:

Invoked to return an array of filenames that the receiver promises to create.

Deprecated
- collectionView:draggingImageForItemsAtIndexes:withEvent:offset:

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

- collectionView:draggingSession:willBeginAtPoint:forItemsAtIndexes:

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

- collectionView:validateDrop:proposedIndex:dropOperation:

Validates the specified location to see if it is a valid drop target.

- collectionView:acceptDrop:index:dropOperation:

Invoked when the mouse is released over a collection view that previously allowed a drop.