Using TreeExpanderButtons in Adornments

Hi walter!

I am trying to use a TreeExpanderButton in an Adornment that is shown when a node is selected. Everything seems to work well so far, except for the fact that the button state is always collapsed [-]. This is how I trigger the Adornment:

            if (node.isSelected) {
              nodeToolsAdornment.adornedObject = node;
              nodeToolsAdornment.data = node.data;

              node.addAdornment("nodeTools", nodeToolsAdornment);

It seems that the button cannot bind to the right isTreeExpanded property. Any hint?

You can see how the “TreeExpanderButton” is defined starting at line 218 of GoJS/Buttons.ts at master · NorthwoodsSoftware/GoJS · GitHub

Note how the two Bindings have source properties, “isTreeExpanded” and “isTreeLeaf”, on the GraphObject button’s Part due to the binding being Binding.ofObject. But if the button is in an Adornment, it’s not in a Node. The Adornment class does not have those two properties.

The “TreeExpanderButton” definition would need to be changed to work in an Adornment instead of a Node. But you can copy and adapt the code to do what you want.

Alright, thanks for clarifying this! I will try your proposed solution. Most probably I would have had to define a custom expander button anyway, so thanks for the link.

Happy Friday! :)