Button Disabling

I have a button that I want to disable (i.e. make desaturated and not clickable).

Looking at the system given, it looks like I would be out of luck except to add and remove activators, maybe…

Can anyone help me figure out what I would need to do with UI Elements to disable the button via code.

You can use the “SetEnabled” method on the VisualElement class. Be aware to check if “button.enabledSelf” returns true in the clicked-callback. My clicked-handlers were sometimes called, even though the button was disabled.

This will also add the pseudo class “:disabled” to the element, so you can style your button accordingly.

1 Like