From c78bafd0005272c9db9a0c7fa8de9861871102be Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 15 Apr 2022 14:18:55 +0200 Subject: [PATCH] Ensure that Element.IsMouseOver is always accurate by making it an auto-property --- CHANGELOG.md | 3 +++ MLEM.Ui/Elements/Element.cs | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c83c1f2..a98ecf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ Additions Additions - Added Element.AutoNavGroup which allows forming groups for auto-navigation +Improvements +- Ensure that Element.IsMouseOver is always accurate by making it an auto-property + 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 diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index 7b579b8..6e9ae99 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -240,7 +240,7 @@ namespace MLEM.Ui.Elements { /// /// Stores whether this element is currently being moused over or touched. /// - public bool IsMouseOver { get; protected set; } + public bool IsMouseOver => this.Controls.MousedElement == this || this.Controls.TouchedElement == this; /// /// Returns whether this element is its 's . /// @@ -439,11 +439,6 @@ namespace MLEM.Ui.Elements { this.size = size; this.Children = new ReadOnlyCollection(this.children); - - this.OnMouseEnter += element => this.IsMouseOver = true; - this.OnMouseExit += element => this.IsMouseOver = false; - this.OnTouchEnter += element => this.IsMouseOver = true; - this.OnTouchExit += element => this.IsMouseOver = false; this.GetTabNextElement += (backward, next) => next; this.GetGamepadNextElement += (dir, next) => next;