Drag-copy with object modification


#1

My GoDiagram app allows users to drag-copy nodes within a view (BTW, I’m distinguishing this action from the external drag-drop that happens when copying nodes are dragged in from a GoPalette container). Pretty basic stuff.



Here’s the problem: From within my overridden GoView.SelectionCopied() event I need a list of the source nodes that were selected and drag-copied, as well as a corresponding list of the new nodes that were created. My ultimate goal is to modify some data values in the “new” node(s) by looking at the values of the source node(s).



Any/all help greatly appreciated. TIA.


#2

The only for-sure way to figure out exactly which copied objects correspond to which original objects is to override GoDocument.CopyFromCollection and look at its return value. That will be a GoCopyDictionary, which maps all original objects (including child parts) to all copied objects.
However, you might be able figure out the mappings of new nodes and old nodes by defining your nodes so that they have a field that has a unique value. Then the copied node and the original node will have the same value for that field, right after the GoView.CopySelection call. If you use the unique IDs generated by setting GoDocument.MaintainsPartID to true, you would just need to add a field holding a copy of the PartID value.