Merge pull request #334 from and3md/radio_button_check_fix

Fixed checking radio button from code.
This commit is contained in:
Vadim Lopatin 2017-04-03 05:06:29 +03:00 committed by GitHub
commit 2433db588a
1 changed files with 14 additions and 2 deletions

View File

@ -485,6 +485,8 @@ class RadioButton : ImageTextButton {
checkable = true;
}
private bool blockUnchecking = false;
void uncheckSiblings() {
Widget p = parent;
if (!p)
@ -494,8 +496,11 @@ class RadioButton : ImageTextButton {
if (child is this)
continue;
RadioButton rb = cast(RadioButton)child;
if (rb)
if (rb) {
rb.blockUnchecking = true;
scope(exit) rb.blockUnchecking = false;
rb.checked = false;
}
}
}
@ -506,7 +511,14 @@ class RadioButton : ImageTextButton {
return super.handleClick();
}
override protected void handleCheckChange(bool checked) {
if (!blockUnchecking)
uncheckSiblings();
invalidate();
checkChange(this, checked);
}
}
/// Text only button