‎2021-02-18 06:07 PM
I am setting the state of a toggle button with forceState(state). I also have an action set up which gets triggered when the button is clicked. Currently I am facing the issue that when I force the state of the button, then I am also getting the action as if the button was clicked. This is completely unnecessary, since I already know which state the button is in. So I have to write some extra code which checks if the action was caused by calling forceState(state) or not. Is there a way to change the behavior, so forceState(state) does not trigger the action or is there a different function for setting the state?
‎2021-02-21 06:44 PM
Hello AWies.1,
This is very strange because I don't reproduce your issue. Moreover, if you look at the code of the forceState() function in ToggleButton.cpp, there's nothing related to ClickEvent in the function.
I believe you didn't implement your button correctly.
Can you enclose your UI to this thread ?
/Alexandre
‎2021-02-22 07:25 PM
Hello Alexandre,
I investigated further and found that the issue does not occur when calling forceState() but after calling invalidate(). I commented out the invalidate() and did not get the unwanted callback any more. However, I am using dual framebuffer, and leaving out invalidate() made the two framebuffers inconsistent. So this is no solution.
On the UI I did not do anything special. I used the TouchGfx designer for the toggle button and also for defining the click handler.
Alex
‎2021-02-22 07:36 PM
Hello,
Even if your UI is simple (and actually that's what I'm looking for) please enclose your project.
This will save time for both of us :)
/Alexandre
‎2021-07-07 12:46 AM
Any progress on this? How did you solve your issue?