The last three days I've been trying to create a single row with 4 icons, which you can re-arrange by dragging. I've tried a lot of different approaches, NSCollectionView so far has been the best one. I can now create a NSCollectionView programmatically and add Items to it with an NSArray. However, I still cannot re-arrange the icons/NSCollectionViewItems. I'm pretty stuck right now and hope one of you guys can point me in the right direction.
I've read a lot of similar questions on stackoverflow (and the entire internet). There it became clear that I needed to add methods from NSCollectionViewDelegate:
- (BOOL)collectionView:(NSCollectionView *)collectionView writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pasteboard
-(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've added these (with return values) to my NSCollectionView subclass, and still I get nothing. So the question I have right now is: should I create a subclass of the NSCollectionViewDelegate and override these methods there?
But is this really going in the right direction? (As you've probably noticed, I'm a Cocoa beginner, so I'm pretty lost right now as I find the NSCollectionView class very confusing.)
Thanks in advance, Frans