cancel
Showing results for 
Search instead for 
Did you mean: 

Setting state of toggle button causes click handler to trigger

AWies.1
Associate III

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?

4 REPLIES 4
Alexandre RENOUX
Principal

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

AWies.1
Associate III

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

Alexandre RENOUX
Principal

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

ADepr.1
Associate II

Any progress on this? How did you solve your issue?