From 1f4f0cfa44cdb31879973de642d7a28cacbdc7e8 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 17 Mar 2022 20:45:28 +0100 Subject: [PATCH] Fixed Element.IsSelected returning incorrect results when CanBeSelected changes --- CHANGELOG.md | 2 +- MLEM.Ui/Elements/Element.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb389ef..bdd681c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,7 +61,7 @@ Fixes - Fixed UiControls allowing for non-selectable or non-mouseable elements to be marked as selected or moused - Fixed buttons and checkboxes changing their CanBeSelected and CanBePressed values when being disabled - Fixed children of Panel scroll bars also being scrolled -- Fixed RootElement.CanSelectContent returning incorrect results when CanBeSelected changes in children +- Fixed RootElement.CanSelectContent and Element.IsSelected returning incorrect results when CanBeSelected changes Removals - Marked StyleProp equality members as obsolete diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index d78a6d5..7a57448 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -241,9 +241,9 @@ namespace MLEM.Ui.Elements { /// public bool IsMouseOver { get; protected set; } /// - /// Stores whether this element is its 's . + /// Returns whether this element is its 's . /// - public bool IsSelected { get; protected set; } + public bool IsSelected => this.Root.SelectedElement == this; /// /// Returns whether this element's method has been recently called and its area has not been updated since then using or . /// @@ -436,8 +436,6 @@ namespace MLEM.Ui.Elements { this.OnMouseExit += element => this.IsMouseOver = false; this.OnTouchEnter += element => this.IsMouseOver = true; this.OnTouchExit += element => this.IsMouseOver = false; - this.OnSelected += element => this.IsSelected = true; - this.OnDeselected += element => this.IsSelected = false; this.GetTabNextElement += (backward, next) => next; this.GetGamepadNextElement += (dir, next) => next;