WRadioButton: Signal unChecked() is never emitted
Added by Stefan Bn about 4 years ago
Hi there,
I was wondering about the following behavior (in Wt 4.4.0):
In a WButtonGroup of WRadioButtons only one RadioButton can be checked at a time. When the user changes the selection, the newly selected RadioButton fires its changed() and its checked() event. However, I would have expected that the previous selected RadioButton then emits its unChecked() and changed() events as well. This is not the case, the previous selected RadioButton neither emits unChecked() nor changed() events.
Is this a bug or a expected behavior? :-) (Since WRadioButton provides the unChecked() Signal it should be fired I guess ..)
Best,
Stefan
Replies (6)
RE: WRadioButton: Signal unChecked() is never emitted - Added by Alexandra S about 3 years ago
I encountered the same problem (or feature?). Did you ever find out whether it is intended behaviour or not?
Thanks,
Alexandra
RE: WRadioButton: Signal unChecked() is never emitted - Added by Roel Standaert about 3 years ago
I think it makes sense that unChecked()
should be emitted if it is as a result of a client side event. I'll discuss it with the team.
I suppose being an EventSignal
it's normally associated with some DOM event, and I guess we're not actually getting that event if it's as a result of checking another radio button.
It doesn't usually crop up since the typical signal to use with a group of radio buttons is WButtonGroup::checkedChanged()
.
RE: WRadioButton: Signal unChecked() is never emitted - Added by Roel Standaert about 3 years ago
The browser indeed emits a change
and input
event when a radio button is checked, but not when it is unchecked as a result of checking another radio button.
Wt's behavior is thus consistent with how the browser does it. I don't know if we then should deviate from it.
RE: WRadioButton: Signal unChecked() is never emitted - Added by Stefan Bn about 3 years ago
Thanks for the clarification! Since WRadioButton can not be toggled (as opposed to WCheckBox), there seems to be no use case ever that will trigger the unChecked()
signal.
I can live with that, at least it shout be part of the Wt documentation so that every developer knows, with a reference to WButtonGroup::checkedChanged()
.
RE: WRadioButton: Signal unChecked() is never emitted - Added by Roel Standaert about 3 years ago
I made an issue for it: https://redmine.emweb.be/issues/9264
RE: WRadioButton: Signal unChecked() is never emitted - Added by Alexandra S about 3 years ago
Thanks for the explanation! Would it maybe make sense (for a future version) to have the WButtonGroup::checkedChanged()
also report the button that was previously checked? Then one could connect to that signal and emit the unchecked signal manually if one wanted to (or do the stuff for the unchecked button right there).