Toggle button state, with unique values, then trigger different graphics or background? #2935
Replies: 3 comments
-
For Text, that can easily be controlled with a variable by setting the button to Expression mode (the button on the right of the text box) and use a conditional operator such as As for Background, you can use the feedback For changing the variable, you could either use |
Beta Was this translation helpful? Give feedback.
-
Ah... Thanks. Now the fun begins. |
Beta Was this translation helpful? Give feedback.
-
So there was a slight issue with the above example or explanation... The test logic must always test for 'true' as a string, not just true boolean. Button text expression was testing variable as boolean, but the Set with expression press action was correct as testing against a string 'true'. Once I realized this, the toggle logic worked like a charm and the button title changed as expected. For for anyone that might find this discussion helpful, you also need to decide the start state of the custom variable, in my case, the current value as false as a string no quotes needed, and start state value as false again as string value. Then the Button expression logic... The press action... As I noted above, on each test, i.e. $variable == 'true' is comparing variable to a string type not a boolean type. I have learned that Companion given how it evaluates expressions, can resolve in weird ways if you to not use strict variable typing. Depending on your situation you might want to set the initial start state based on some type of trigger or feedback. In my case I am using http generic module to communicate to Revision's ProPresenter application, and I have not as yet found the right REST API call to get the startup state. Once I find the right way to get the start up state I will update my button logic of course. Thanks to @thedist for his suggestion, without his help, I would have spent a lot of time hacking away at this question to solve it. |
Beta Was this translation helpful? Give feedback.
-
I have a use case, where I want one button to toggle between two values, usually 'true' or 'false, and use the button state as way of setting the button background and button text. Something like:
When button 'Off'...
Text: 'Off'
Background: Green
Value of Variable: false
When button 'On'...
Text: 'On'
Background: Red
Value of Variable: true
Given this will be across several modules, I guess I need a pretty generic way to do this? Maybe each press, i.e. on/off step sets variable unique to the given button, then that value used to determine button text and background on release?
But being new to Companion, not clue how to even start to do this? Any help create appreciated.
Beta Was this translation helpful? Give feedback.
All reactions