I’ve got a slider with a valueBox label below it, and a button which sets the value of the slider when pressed.
All works well except when the user has changed the text in the valueBox, but not hit return to confirm the change. If they then press the button, the value in the valueBox ends up being the unconfirmed value, not the value applied by the button.
This happens because of a conflict between Slider::setValue(), and the valueBox’s TextEditor loosing focus. The TextEditor looses focus, and sends a message to the Slider. Before it’s received, the slider gets set to a new value by the button press. Then Slider::labelTextChanged() is called with the old, unconfirmed value, and the slider dutifully applies that to the valueBox, overriding the value set by the button.
I thought I could work around this by subclassing and changing Slider::setTextBoxIsEditable() so that the TextEditor would discard changes when it looses focus, rather than honoring them, but valueBox is a private member of the Slider class, so I can’t change any of it’s parameters when it’s created there.
Is there a way to deal with this problem?