0

I'm working on the app that displays svg icons inside NSCollectionView. I want to implement drag&drop feature to allow users drags svg to Finder or another app. There are I have two questions:

1.) To implement drag to another app I'm using NSFilenamesPboardType for registerForDraggedTypes and in collectionView:writeItemsAtIndexes:toPasteboard: create temp file and write it URL to [pasteboard writeObjects:@[fileURL]]; because collectionView:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAtIndexes:not called in this case. Is it correct implementation? I cannot find how to implement drag&drop for svg in another way.

2.) How I can receive callback that drop ended? NSTableView in data source has method tableView:draggingSession:endedAtPoint:operation which determines end of drag. For NSCollectionView this method not documented, but exist in NSCollectionViewDelegate. Can I use it and app will pass the review?

Thanks for any advice

2 Answers2

1

There is an NSCollectionViewDelegate method that was available with 10.7:

- collectionView:draggingSession:endedAtPoint:dragOperation:

It calls the method AFTER the item is dropped to receiving application.

seyf
  • 26
  • 2
0

collectionView:namesOfPromisedFilesDroppedAtDestination:forDraggedItemsAtIndexes: will be called if you use NSFilesPromisePboardType. You create the files after the drop. If the other application doesn't accept promised files, this won't work.

It looks like Apple forgot to add the new drag and drop delegate methods of 10.7 to the documentation of NSCollectionViewDelegate. You can use them.

Willeke
  • 14,578
  • 4
  • 19
  • 47