I'm trying to figure out how to implement drag and drop from within a NSOutlineView to itself.
For example, I want the user to be able to reorder and nest and re-nest the items in the NSOutlineView, but I don't need to be able to drag items from any other source (like files or from another view).
All the examples I can find deal with dragging item into the NSOutlineView, not just within itself and seem overly complex. I assume this is possible.
Can someone point be to some docs that deal with just this case? Maybe I'm just missing the obvious.
I have found the documentation of this to be somewhat unclear, and among other things the new ways to do it were added in Lion.
Assuming you need this for 10.7 or higher, then this could be a skeleton for you implementation:
In your data source/delegate class, implement:
There is a good deal of code needed to be filled in for the last method, and regarding the animated movement, Apple's complex table view demo code mentioned in samir's comment is quite useful, if somewhat complex to decipher.
I have created a small sample project which has an
NSOutlineView
where you can add and remove items.Today I have implemented Drag and Drop support based on @Monolo's answer (See changes).