Transparency on tool layer


When im dragging a node from the palette onto the diagram I want it to have an opacity of 0.5 until I drop it. I achieved that by using diagram.findLayer(‘Tool’).opacity = 0.5. It currently looks like this:


The problem is that I have a context menu defined on the hamburger menu in each node. But this opacity is affecting that menu as well. Even my context menu has an opacity of 0.5 due to this, as seen below:


How can I prevent this?

There are several possibilities, depending on the exact behaviors that you want.

One way would be to set the Layer.opacity only when the Palette’s DraggingTool is active. You can do that by overriding the DraggingTool.doActivate and doDeactivate methods:

        $(go.Palette, "myPaletteDiv",
            nodeTemplateMap: myDiagram.nodeTemplateMap,
            "draggingTool.doActivate": function() {
              myDiagram.findLayer("Tool").opacity = 0.5;
            "draggingTool.doDeactivate": function() {
              myDiagram.findLayer("Tool").opacity = 1.0;

I am using this in an angular application and i gave the doActivate and doDeactivate functions for the paletter tool manager in the ngOnInit function.

I have a different nodeTemplateMap for the palette and diagram. Which are also defined in the same function.

But im now unable to pick up any elements from the palette. Im getting the following error:

No Node template found for category “component”
go.js:17 Using default node template
core-error-handler.service.ts:18 Unhandled exception caught by iiot-core!
Cannot read property ‘canMove’ of undefined

What is the issue here?

Here are the 2 functions:

this.palette.toolManager.draggingTool.doActivate = () => {;
          this.diagram.findLayer("Tool").opacity = 0.5;
    this.palette.toolManager.draggingTool.doDeactivate = () => {;
          this.diagram.findLayer("Tool").opacity = 1.0;

Update: changed the snippet according to with regard to overriding functions. Working as expected now!