I'm pretty new to Cocoa, and I'm developing an application that does drag/drop from and into NSOutlineView
.
I've implemented "outlineView:validateDrop:proposedItem:proposedChildIndex
", and "outlineView:acceptDrop:item:childIndex:
" methods to make an NSOutlineView
a destination for dropping. It works all fine, except that it tries to specify a row/location into which the items from a different NSOutlineView
should be dropped.
My application doesn't really need to specify which row the item should be dropped on or above; ideally, I would like to have the entire NSOutlineView
box highlighted when I drag-and-drop onto the NSOutlineView
. Row selection will be done programmatically.
How can I accomplish this?
You're going to want to use NSOutlineView
's setDropItem:dropChildIndex:
to programmatically set the index to insert at.
For highlighting the entire outline view, you may want to try NSTableView
's setDropRow:dropOperation:
setting the dropRow at -1, which the doc says:
Passing a value of –1 for row, and NSTableViewDropOn as the operation causes the entire table view to be highlighted rather than a specific row. This is useful if the data displayed by the receiver does not allow the user to drop items at a specific row location.
NSOutlineView inherits from NSTableView, so this might work if the NSOutlineView subclass doesn't screw up the highlighting behavior of NSTableView.