Hi
I may be being dim today, and I can’t intuit my way from a dragged part to the node data. Should be an easy one to answer I hope.
Scenario: A diagram with a node on it. I put the mousedown on the node, drag it a bit, then let the mouse up. I have subclassed the dragTool.doDeactivate() function. In that function I want to get the key for the dragged node, so I iterate on the draggedParts, as:
var it = this.draggedParts.iterator;
var obj = null
while (it.next()) {
obj = it.value;
if ( obj instanceof go.Node ) {
console.log('I am getting here ok!')
if (obj.data) {
console.log('I am NOT getting here')
console.log('node key=' + obj.data.key) // never happens
}
}
}
go.DraggingTool.prototype.doDeactivate.call(dragTool); // pass on to main tool
[Update] I have an alternative solution using the diagram ‘SelectionMoved’ listerner, however I am now even more curious how to make the above work since the diagram.selection is 'read-only collection of selected objects.’ via which one can get a handle to the first of the selected nodes via:
var obj = myDiagram.selection.iterator.first();
I guess I am struggling to understand the difference between the diagram.selection (evidently a collection of node references) and the draggedParts (defined in the docs as ‘a Map mapping Parts to DraggingInfo Objects’). By the way, this Google search of the docs site shows no hits for DraggingInfo outside the draggingTool page. - maybe worth documenting and throwing in a sample ?