Is there a way to set a button value to 0 if it is disabled?

I am new to ignition and still trying to figure my way through the syntax.

Edit: I am talking about changing the “Selected” property of a button to 0 if it is disabled.

I’m a little confused as to what you’re trying to accomplish, and where you’re trying to do this. Are you in Perspective, or Vision? Neither context has a “selected” property for its button component, though both could support such a value as a custom property.

So for me to truly help you, I’m going to need a better understanding of what you’re trying to accomplish.


Its going to end up being for vision but I just opened up the designer, I don’t think I have any modules set just yet.

Selected is the output of the button. So if the button is clicked then selected goes true. That is then tied back to whatever tag value is set.

Oh, you’re using a Radio Button, NOT a Button. Their behaviors are totally different.

No, there isn’t because of how Radio Buttons behave. Radio Buttons must follow a certain set of rules; a Radio Button GROUP may only ever have one Radio Button selected at a given time, once any Radio Button is selected within a group, there must always be one radio Button within the group selected.

Based on these rules, you are NOT able to set your Radio Button to not be selected, because it would violate the rule which requires that one Radio Button always be selected.

What you COULD do, is place a propertyChange event on the Radio Button in question, and if the ‘enabled’ property changes, set a DIFFERENT Radio Button to be selected (a sort of “fallback” value). Performing this action would not violate any of the Radio Button Group rules.

Unless you’re using a Toggle Button…
Then you could use

if event.propertyName == 'enabled':
    if not event.newValue:  # equates to True if the event.newValue is False
        event.source.selected = False