mirror of https://github.com/buggins/dlangui.git
Merge pull request #334 from and3md/radio_button_check_fix
Fixed checking radio button from code.
This commit is contained in:
commit
2433db588a
|
@ -485,6 +485,8 @@ class RadioButton : ImageTextButton {
|
||||||
checkable = true;
|
checkable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool blockUnchecking = false;
|
||||||
|
|
||||||
void uncheckSiblings() {
|
void uncheckSiblings() {
|
||||||
Widget p = parent;
|
Widget p = parent;
|
||||||
if (!p)
|
if (!p)
|
||||||
|
@ -494,10 +496,13 @@ class RadioButton : ImageTextButton {
|
||||||
if (child is this)
|
if (child is this)
|
||||||
continue;
|
continue;
|
||||||
RadioButton rb = cast(RadioButton)child;
|
RadioButton rb = cast(RadioButton)child;
|
||||||
if (rb)
|
if (rb) {
|
||||||
|
rb.blockUnchecking = true;
|
||||||
|
scope(exit) rb.blockUnchecking = false;
|
||||||
rb.checked = false;
|
rb.checked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// called to process click and notify listeners
|
// called to process click and notify listeners
|
||||||
override protected bool handleClick() {
|
override protected bool handleClick() {
|
||||||
|
@ -507,6 +512,13 @@ class RadioButton : ImageTextButton {
|
||||||
return super.handleClick();
|
return super.handleClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override protected void handleCheckChange(bool checked) {
|
||||||
|
if (!blockUnchecking)
|
||||||
|
uncheckSiblings();
|
||||||
|
invalidate();
|
||||||
|
checkChange(this, checked);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Text only button
|
/// Text only button
|
||||||
|
|
Loading…
Reference in New Issue