Skip to main content
Xxoyo.1
Associate III
May 4, 2021
Solved

Setting toggle button to a specific state programmatically

  • May 4, 2021
  • 3 replies
  • 3060 views

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...

This topic has been closed for replies.
Best answer by Romain DIELEMAN

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

3 replies

Romain DIELEMAN
Romain DIELEMANBest answer
ST Employee
May 4, 2021

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

Xxoyo.1
Xxoyo.1Author
Associate III
May 4, 2021

This is exactly what I have left out :grinning_face_with_sweat:

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
}

Romain DIELEMAN
ST Employee
May 4, 2021

perfect :beaming_face_with_smiling_eyes: