Javascript: set Pressed state of a button

By default buttons in 3DVista are set to Pushed. That means they return to their original state right away. With a Pressed button, you can change the button to the other state. True/False, On/Off, Play/Pause,Mute/Unmute, whatever you think of. But sometimes the situation changes and the state is still set to False while you might need it to be set to True. In these situations this Javascript code is very useful. Beside the click on the button itself, the button state can be changed by an action that is elsewhere triggered.

For the code to work, you can change to true or to false. For the text to change, you change that in Edit Styles in the text field.

this.getComponentByName('UNIQUEBUTTONNAME').set('pressed', true);
Copy code
Ronald van der Weijden
May 30, 2023

Learn from our Tutorials

1000's of hours already watched by our community the last year