Using 1.6.18.
Added a clipboard handler to move the copied nodes on the mouse position. However, sometimes the links are not moved.
diagram.addDiagramListener("ClipboardPasted", clipboardPasted);
function clipboardPasted(e) {
var firstSelection = diagram.selection.first();
if (!firstSelection) return;
var mouseLocation = diagram.lastInput.documentPoint;
var displaceX = mouseLocation.x - firstSelection.location.x + firstSelection.actualBounds.width / 2;
var displaceY = mouseLocation.y - firstSelection.location.y + firstSelection.actualBounds.height / 2;
//diagram.startTransaction("pasteclipboard");
diagram.selection.each(function (current) {
if (current instanceof go.Link) return; // skips over go.Link
current.move(new go.Point(displaceX + current.location.x - current.actualBounds.width / 2, displaceY + current.location.y - current.actualBounds.height / 2));
});
//diagram.commitTransaction("pasteclipboard");
}
See picture: CTRL-A, moved mouse, press background, CTRL-V. The nodes are perfectly positioned, the links are still highlighted on the original links.
See picture: Using the move keys to move the selected nodes to make it better visible.
Moving the nodes with the mouse, paints the links correct.
I am also using the centerX and centerY from DrawCommandHandler, which behaves correct. Any idea, why my links are not moved with the above (similar) code?