cancel
Showing results for 
Search instead for 
Did you mean: 

Toggle button

heyo
Senior

Is it possible to change toggle button state?

1 ACCEPTED SOLUTION

Accepted Solutions
Osman SOYKURT
ST Employee

Hello heyo,

Yes, by default the toggle button will react when you click on it and you can get the status of your toggle button with this function :

toggleButton1.getState()

If you want to set a state yourself, you can use this function :

toggleButton1.forceState(!toggleButton1.getState());
// here it will invert your toggle button state, so if true then false, and if false then true

I created a small example that you can get inspiration from if you want.

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX

View solution in original post

1 REPLY 1
Osman SOYKURT
ST Employee

Hello heyo,

Yes, by default the toggle button will react when you click on it and you can get the status of your toggle button with this function :

toggleButton1.getState()

If you want to set a state yourself, you can use this function :

toggleButton1.forceState(!toggleButton1.getState());
// here it will invert your toggle button state, so if true then false, and if false then true

I created a small example that you can get inspiration from if you want.

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX