sylvain
December 14, 2022, 10:41am
#1
Hello,
When I’m in the palette, when I move a node in the diagram, I would like the dragged node change color and outline.
I can change opacity with
myDiagram.findLayer(“Tool”).opacity = 0.5;
but I can’t change color.
I try with draggingTool, dragSelectingTool or mouseDragEnter but nothing works.
Could you help me?
Thanks in advance.
walter
December 14, 2022, 1:04pm
#2
The most general solution is to override methods of the DraggingTool that your Diagram and that your Palette use. For example:
class CustomDraggingTool extends go.DraggingTool {
doDragOver(pt, obj) {
const parts = this.copiedParts || this.draggedParts;
if (parts) parts.iteratorKeys.each(node => {
if (!(node instanceof go.Node)) return;
node.elt(0).fill = "lime";
});
}
doDeactivate() {
const parts = this.copiedParts || this.draggedParts;
if (parts) parts.iteratorKeys.each(node => {
if (!(node instanceof go.Node)) return;
node.elt(0).fill = "white";
});
super.doDeactivate();
}
}
You will need to adapt this code to perform whatever side-effects you want to show in the dragged nodes.
To install this tool:
$(go.Diagram, . . .,
{
draggingTool: new CustomDraggingTool(),
. . .
})
for both your main Diagram and your Palette.