On Hover Node

Hi, On hover of the red node ( its a shape) I need to find the node ( its tree) on the same line which is having an underline. And update text color only on hover. Can you help to achieve this?

1 Like

If that arrow is part of your node, then on that Shape, you can add mouseEnter and mouseLeave properties on it, and in these properties, find the TextBlock and change its stroke. You must give your TextBlock a name in order to use findObject.

Here’s a basic example. Hover over the Diamond shape and the Textblock stroke changes from black to red:

myDiagram.nodeTemplate = $(go.Node, "Vertical",
   $(go.Shape, {
      figure: 'diamond', width: 30, height: 30, fill: 'lightblue',
      mouseEnter: function(e, obj) {
        obj.part.findObject("TEXT").stroke = "red";
      },
      mouseLeave: function(e, obj) {
        obj.part.findObject("TEXT").stroke = "black";
      }
    }
    ),
    $(go.TextBlock, "test", {
            name: 'TEXT',
            margin: 8,
            font: "700 18pt sans-serif"
        }
    )
);

Live example:

2 Likes

Thanks for quick solution its worked as expected