Hi everyone. I’m new to ignition.
I have a multi state button, I’d like to show a message box stating that the current button is already active when the said button is pressed again. I was thinking of using tag event script with the previous and current value in the value changed but I have noticed that the value does not pass/change if the same button is pressed. What possible alternatives can I use so I can track the changes/action in the said multi state button?
First off, a tag change script can’t open a message box in your Vision client since it is gateway-scoped without something like a message handler. I would skip a message box all together as I don’t see what it will accomplish. With correct styling on the component, you can tell which state you’re in.
Right Click multi-state button → Customizers → Multi-State Button Customizer or
ctrl + u
If you really want to see when the button is pressed when already active, you would add a property change script. Right click the component, and select scripting. In the
propertyChange event handler put
if event.propertyName == 'controlValue' and event.newValue == event.oldValue:
print 'No state change'
It will print in the console under
Thank you for the comment. I have tried writing the script on the property change of multi state button but there seems to be a problem (which I don’t know of) because it does not print in the console. Although, there was no error entering the script. May I know what other things should I check?
Evidently, the multi-state button does not have an accurate
oldValue. When I print out oldValue, it always comes back as
None. The work around is to add a custom property to the component, I made one called
lastState and used this script
if event.propertyName == 'controlValue':
if event.source.lastState != event.newValue:
event.source.lastState = event.newValue
print 'State did not change'
I have replaced the print to system.gui.errorBox and voila! It worked!. Thank you so much for your help.