0
votes

I have a view based NSOutlineView (written in Objective C) which supports dragging from any row in the tree. Multiple row selection by the user is not allowed. I adjust what is being dropped in the outlineView:acceptDrop:item:childIndex delegate method to automatically include all necessary parent and child rows. The actual drag operation works fine.

My issue is with the visual component of what is being dragged. I can use outlineView:selectionIndexesForProposedSelection to modify selections when a selection is made. (My visual select style is NSTableViewSelectionHighlightStyleNone). This also works find as the required components are visually represented in the drag.

The problem is that the user does not have to select a row to begin a drag. When a drag commences this way outlineView:selectionIndexesForProposedSelection is not called and only the dragged row is displayed during the drag. The actual drag operation still works as intended.

I've played with all the datasource and delegate methods but I can't seem to find a way to change what is initially dragged so that NSOutlineView will show images for the rows that I include.

It seems as if outlineView:updateDraggingItemsForDrag should work but it does not let me change the source of the drag.

It seems as if NSOutlineView's determination of what to highlight during a drag is made based on the selection. Regardless as to how many items I place on the pasteboard it is always the selected items which are highlighted.

Any ideas as to how to force a selection change on the start of a drag?

1

1 Answers

0
votes

It turns out that simply subclassing NSOutlineView and using mouseDown I get in safely before anything else starts. Setting the selection works fine as the subsequent possible and does not seem to mess up a possible selection change on the same click.