cancel
Showing results for 
Search instead for 
Did you mean: 

Setting toggle button to a specific state programmatically

Xxoyo.1
Associate III

I have a toggle button widget directly dragged from TouchGFX designer to the UI.

I am unable to manually set the state of the toggle button to True/False using the ForceState (it just flashes between True/False every time I set the state )

Is there a way to i.e. setState() the toggle button and update it's corresponding image?

Thanks...

1 ACCEPTED SOLUTION

Accepted Solutions
Romain DIELEMAN
ST Employee

Hi,

Could you share your code ? Just to be sure have you made sure you used the .invalidate function after changing the state of the button ?

/Romain

View solution in original post

3 REPLIES 3
Romain DIELEMAN
ST Employee

Hi,

Could you share your code ? Just to be sure have you made sure you used the .invalidate function after changing the state of the button ?

/Romain

This is exactly what I have left out 😅

Now everything is working as expected

I updated my code to this

void Container_MiniStatus::setToggleButtonState(bool value)
{
	toggleButton1.forceState(value);
	toggleButton1.invalidate();   //ADDED LINE
}

perfect 😁