alexrozanski / PXSourceList

Source List control for the Mac
Other
638 stars 76 forks source link

Drag and drop methods are never called #42

Closed jdrukman closed 10 years ago

jdrukman commented 10 years ago

I have a master-detail type of app using PXSourceList as an itunes-type sidebar. I want to be able to drag from a tableview on the detail pane to an item on the sourcelist. (Think iTunes add to playlist functionality.) I am using a view-based PXSourceList. I can initiate a drag from within the sourcelist if I implement sourceList:writeItems:toPasteboard:, but that's not what I want. I want it to accept a drag from outside itself. Is that even possible? Right now I have implemented all 3 methods but neither acceptDrop nor validateDrop is being called.

swaterfall commented 10 years ago

I'm trying to figure this out, how did you fix it?

jdrukman commented 10 years ago

I forgot to call [sourcelist registerForDraggedTypes:]. Once you do that, you only need to implement -(NSDragOperation)sourceList:(PXSourceList *)sourceList validateDrop:(id<NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index and -(BOOL)sourceList:(PXSourceList *)aSourceList acceptDrop:(id<NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index

swaterfall commented 10 years ago

Ah great, thanks!

alexrozanski commented 10 years ago

Yep, thanks for the write-up! PXSourceList basically mirrors how NSOutlineView and NSTableView work with regards to drag-n-drop.