I have an NSCollectionView associated with an NSArrayController. I want to work with drag and drop, so I create a delegate and implement methods
-(BOOL)collectionView:(NSCollectionView *)collectionView canDragItemsAtIndexes:(NSIndexSet *)indexes withEvent:(NSEvent*)event -(BOOL)collectionView:(NSCollectionView *)collectionView acceptDrop:(id < NSDraggingInfo >)draggingInfo index:(NSInteger)index dropOperation:(NSCollectionViewDropOperation)dropOperation -(NSDragOperation)collectionView:(NSCollectionView *)collectionView validateDrop:(id < NSDraggingInfo >)draggingInfo proposedIndex:(NSInteger *)proposedDropIndex dropOperation:(NSCollectionViewDropOperation *)proposedDropOperation -(NSArray *)collectionView:(NSCollectionView *)collectionView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropURL forDraggedItemsAtIndexes:(NSIndexSet *)indexes
I am returning YES for two BOOL methods, NSDragOperationMove for the validateDrop: method and an empty array for the namesOfPromisedFilesDroppedAtDestination: method. I also have an NSLog statement as the first line in each method, so I can see when they are called.
Currently, the only method that is called is canDragItemsAtIndexes: (where I return YES). I see that it is called, but any further drag and drop just changes the selection. The rest are never called.
If I make NSCollectionView not support selection, then even this method is not called.
I am sure that I am missing something beyond the obvious, but I cannot understand what it is. Has anyone got drag and drop while working with NSCollectionViews, and can shed some light?
source share