From 21dce9d60aa87b1f9c9f5dab2ee526dc95eb9b04 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 4 Sep 2019 15:36:47 +0200 Subject: [PATCH] fixed an issue where already removed uis would still be selectable --- MLEM.Ui/UiControls.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MLEM.Ui/UiControls.cs b/MLEM.Ui/UiControls.cs index 0bd1ef0..1bb979b 100644 --- a/MLEM.Ui/UiControls.cs +++ b/MLEM.Ui/UiControls.cs @@ -54,7 +54,7 @@ namespace MLEM.Ui { // KEYBOARD INPUT else if (this.Input.IsKeyPressed(Keys.Enter) || this.Input.IsKeyPressed(Keys.Space)) { - if (this.SelectedElement != null) { + if (this.SelectedElement?.Root != null) { if (this.Input.IsModifierKeyDown(ModifierKey.Shift)) { // secondary action on element using space or enter this.SelectedElement.OnSecondaryPressed?.Invoke(this.SelectedElement); @@ -109,8 +109,8 @@ namespace MLEM.Ui { var currRoot = this.system.GetRootElements().FirstOrDefault(root => root.CanSelectContent); if (currRoot == null) return null; - var children = currRoot.Element.GetChildren(regardChildrensChildren: true); - if (this.SelectedElement == null || this.SelectedElement.Root != currRoot) { + var children = currRoot.Element.GetChildren(regardChildrensChildren: true).Append(currRoot.Element); + if (this.SelectedElement?.Root != currRoot) { return backward ? children.LastOrDefault(c => c.CanBeSelected) : children.FirstOrDefault(c => c.CanBeSelected); } else { var foundCurr = false;