Updownquark / Quick

Quark's User Interface Creation Kit
0 stars 0 forks source link

Add utility for listener stack #41

Closed Updownquark closed 11 years ago

Updownquark commented 11 years ago

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:

  1. The user clicks a selected toggle buton
  2. The selected state changes to false
  3. 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
  4. 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.
  5. 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.

Updownquark commented 11 years ago

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.