Hide buttons in palette and when isReadOnly

Hi,

I’m very new to gojs but seems very nice.

A have nodes with a selectAdornment which adds a button to my node. I don’t want this button to be added when selecting nodes in the palette.

Also when i set my diagram to isReadOnly = true and the user selects a node, I don’t want the button to be visible.

How do I achieve this?

Thanks

Add this Binding to the button (or whatever you want to hide when the Diagram.isReadOnly):

new go.Binding("visible", "", function(o) { return !o.diagram.isReadOnly; }).ofObject()

If you are changing the Diagram.isReadOnly state dynamically, you may need to call Diagram.updateAllTargetBindings(), although for efficiency you do not want to call this often!

Worked great. Thanks!