diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1c7dbf4..6fba1b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -54,6 +54,7 @@ Fixes
- Fixed paragraph links having incorrect hover locations when using special text alignments
- Fixed the graphics device's viewport being ignored for mouse and touch queries
- Fixed auto-navigating panels not scrolling to the center of elements properly
+- Fixed UiControls allowing for non-selectable or non-mouseable elements to be marked as selected or moused
Removals
- Marked StyleProp equality members as obsolete
diff --git a/MLEM.Ui/UiControls.cs b/MLEM.Ui/UiControls.cs
index 9407cdf..9697292 100644
--- a/MLEM.Ui/UiControls.cs
+++ b/MLEM.Ui/UiControls.cs
@@ -259,7 +259,9 @@ namespace MLEM.Ui {
/// The element to select, or null to deselect the selected element.
/// Whether automatic navigation should be forced on
public void SelectElement(RootElement root, Element element, bool? autoNav = null) {
- if (root == null)
+ if (root == null || !root.CanSelectContent)
+ return;
+ if (element != null && !element.CanBeSelected)
return;
var selected = this.GetSelectedElement(root);
if (selected == element)
@@ -284,6 +286,8 @@ namespace MLEM.Ui {
///
/// The element to set as moused
public void SetMousedElement(Element element) {
+ if (element != null && !element.CanBeMoused)
+ return;
if (element != this.MousedElement) {
if (this.MousedElement != null)
this.System.InvokeOnElementMouseExit(this.MousedElement);
@@ -299,6 +303,8 @@ namespace MLEM.Ui {
///
/// The element to set as touched
public void SetTouchedElement(Element element) {
+ if (element != null && !element.CanBeMoused)
+ return;
if (element != this.TouchedElement) {
if (this.TouchedElement != null)
this.System.InvokeOnElementTouchExit(this.TouchedElement);
@@ -316,9 +322,11 @@ namespace MLEM.Ui {
/// The root element whose selected element to return
/// The given root's selected element, or null if the root doesn't exist, or if there is no selected element for that root.
public Element GetSelectedElement(RootElement root) {
- if (root == null)
+ if (root == null || !root.CanSelectContent)
return null;
this.selectedElements.TryGetValue(root.Name, out var element);
+ if (element != null && !element.CanBeSelected)
+ return null;
return element;
}