Handling events from checkbox click

I’m looking for a simple example of how to handle click events from the Checkbox control. Given this simple control:

$(go.Panel, "Auto", { stretch: go.GraphObject.Horizontal },
        { "_buttonFillOver": "pink", "_buttonStrokeOver": "red"},
                margin: new go.Margin(0, 5),
                column: 1, 
                font: "bold 13px sans-serif",
                // and disallow drawing links from or to this text:
                fromLinkable: false, toLinkable: false
            new go.Binding("text", "name")

How would I attach to the click event handler for the checkbox and read it’s state assuming more than one checkbox?

I hope you have seen this sample already: CheckBoxes

The “CheckBox” when clicked will toggle the data.checked property of the node or link data object in the model. That’s because you named the data property by specifying “checked”. Presumably if you have more than one checkbox you’ll use different data property names.

As with all changes to the model, the change is performed within a transaction. So one way to notice the change is by implementing a Model Changed listener, look for a “checkbox” transaction, and then get the state by looking at the data.checked property.

Or you could look at the visible property of the “ButtonIcon” Shape of the “CheckBox” Panel. (You can determine that by looking at how the “CheckBox” is implemented in https://gojs.net/latest/extensions/Buttons.js. Look in the definition of “CheckBoxButton”.) But this is usually less convenient, and might be less reliable if the checkbox is re-implemented or re-styled.