How to change the color of a dragged node

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.

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.