From cd1cc7c1f612dea99593f504f1cd50718b45994e Mon Sep 17 00:00:00 2001 From: and3md Date: Wed, 22 Mar 2017 20:11:47 +0100 Subject: [PATCH] Fixed checking radio button from code. --- src/dlangui/widgets/controls.d | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/dlangui/widgets/controls.d b/src/dlangui/widgets/controls.d index f1ff04b8..fdf77dea 100644 --- a/src/dlangui/widgets/controls.d +++ b/src/dlangui/widgets/controls.d @@ -485,6 +485,8 @@ class RadioButton : ImageTextButton { checkable = true; } + private bool blockUnchecking = false; + void uncheckSiblings() { Widget p = parent; if (!p) @@ -494,8 +496,17 @@ class RadioButton : ImageTextButton { if (child is this) continue; RadioButton rb = cast(RadioButton)child; - if (rb) - rb.checked = false; + if (rb) { + rb.blockUnchecking = true; + try + { + rb.checked = false; + } + finally + { + rb.blockUnchecking = false; + } + } } } @@ -506,7 +517,14 @@ class RadioButton : ImageTextButton { return super.handleClick(); } - + + override protected void handleCheckChange(bool checked) { + if (!blockUnchecking) + uncheckSiblings(); + invalidate(); + checkChange(this, checked); + } + } /// Text only button