diff --git a/CHANGELOG.md b/CHANGELOG.md index c5fd404..6a56a10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Additions ### MLEM.Ui Fixes - Fixed auto-nav tooltip displaying on the selected element even when not in auto-nav mode +- Fixed radio buttons not unchecking all other radio buttons with the same root element ## 5.3.0 ### MLEM diff --git a/MLEM.Ui/Elements/RadioButton.cs b/MLEM.Ui/Elements/RadioButton.cs index 3e1e869..f685bd9 100644 --- a/MLEM.Ui/Elements/RadioButton.cs +++ b/MLEM.Ui/Elements/RadioButton.cs @@ -4,7 +4,7 @@ using MLEM.Ui.Style; namespace MLEM.Ui.Elements { /// /// A radio button element to use inside of a . - /// A radio button is a variation of a that causes all other radio buttons in the same to be deselected upon selection. + /// A radio button is a variation of a that causes all other radio buttons in the same to be deselected upon selection. /// public class RadioButton : Checkbox { @@ -26,13 +26,13 @@ namespace MLEM.Ui.Elements { base(anchor, size, label, defaultChecked) { this.Group = group; - // don't += because we want to override the checking + unchecking behavior of Checkbox + // don't += because we want to override the checking/unchecking behavior of Checkbox this.OnPressed = element => { this.Checked = true; - foreach (var sib in this.GetSiblings()) { - if (sib is RadioButton radio && radio.Group == this.Group) - radio.Checked = false; - } + this.Root.Element.AndChildren(e => { + if (e != this && e is RadioButton r && r.Group == this.Group) + r.Checked = false; + }); }; }