Disabling components

I have a weird problem: Two radio-buttons trigger numerous changes in my UI, and the update takes about half a second. If I press the other radiobutton while updating, then this new state will trigger a new update of the UI, and then the fun starts: the old changes somehow disturb, and makes the UI loop back and forth between the two states that correspond to the radiobuttons, which also loop back and forth - completely without pressing them!! It looks funnier than it really is…

I’ve tried the disable the radiobuttons (setEnabled(false)) as the first in the series of changes, but the UI seems to “remember” a mouseclick on the disabled radiobutton, and the problem persists when the other radiobutton becomes active again. Is there another way to disable components? Maybe disable mouse-presses so the events are litterally lost, while updating…?

Thanks in advance!


Enablement is only a hint for the component that it ought to ignore user input - it won’t stop the component’s state getting changed, because you very often want to alter disabled components programatically. It’s your logic that needs fixing so that changes aren’t sent recursively.

Maybe you need to pay more attention to the sendChangeNotification parameter when you call Button::setToggleState…?

Maybe I do… I will, thanks.

Yup, that was a great idea… I followed the sequence of updating calls, and it turned out that resized() was called a grand total of 5 times with each update. This differs slightly between mac and pc (?), but now I’m down to two calls, neither of which can be removed easily - and the UI stopped looping :slight_smile:

  • Thanks, A