There is a bug with toggle buttons. When the user attempts to deselect a selected toggle button (as opposed to selecting a different one) it appears to deselect the button, leaving no buttons selected. In addition, if the user tries to re-select the button, it stays unselected.
The issue is with listeners. The style's state listener gets registered after the model's state listener, so the sequence is:
The user clicks a selected toggle buton
The selected state changes to false
The model listener sets the model value to the button's value. This value was already set, but the listeners fire anyway.
The button's value listener changes the selected state to true
The model's state listener fires, but returns since the model value and the transitioning selected state are both true
The style's state listener fires for the true selected state, changing the look to that of a selected toggle button
The model's value (true) is compared with the transitioning selected state (the original transition, false). The call is made to change the selected state to true, but this returns since the state is already true.
The style's state listener fires for the false selected state, changing the look to that of a selected toggle button.
To correctly solve this problem, the state engine should detect that the secondary state change has fired and cease notifying listeners for the outdated state when control moves back down the stack. Need to make a utility to do this and seek out other places in the code where listeners are called unsafely like this. Not sure yet how to do this without much locking.
As mentioned in the commit, I decided against the utility. It was fairly easy to fix this locally, and I'm not sure a utility would add that much value for when I have to do it again. But this is done.
There is a bug with toggle buttons. When the user attempts to deselect a selected toggle button (as opposed to selecting a different one) it appears to deselect the button, leaving no buttons selected. In addition, if the user tries to re-select the button, it stays unselected.
The issue is with listeners. The style's state listener gets registered after the model's state listener, so the sequence is:
To correctly solve this problem, the state engine should detect that the secondary state change has fired and cease notifying listeners for the outdated state when control moves back down the stack. Need to make a utility to do this and seek out other places in the code where listeners are called unsafely like this. Not sure yet how to do this without much locking.