1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

fixed an issue where already removed uis would still be selectable

This commit is contained in:
Ellpeck 2019-09-04 15:36:47 +02:00
parent f4658aede0
commit 21dce9d60a

View file

@ -54,7 +54,7 @@ namespace MLEM.Ui {
// KEYBOARD INPUT // KEYBOARD INPUT
else if (this.Input.IsKeyPressed(Keys.Enter) || this.Input.IsKeyPressed(Keys.Space)) { 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)) { if (this.Input.IsModifierKeyDown(ModifierKey.Shift)) {
// secondary action on element using space or enter // secondary action on element using space or enter
this.SelectedElement.OnSecondaryPressed?.Invoke(this.SelectedElement); this.SelectedElement.OnSecondaryPressed?.Invoke(this.SelectedElement);
@ -109,8 +109,8 @@ namespace MLEM.Ui {
var currRoot = this.system.GetRootElements().FirstOrDefault(root => root.CanSelectContent); var currRoot = this.system.GetRootElements().FirstOrDefault(root => root.CanSelectContent);
if (currRoot == null) if (currRoot == null)
return null; return null;
var children = currRoot.Element.GetChildren(regardChildrensChildren: true); var children = currRoot.Element.GetChildren(regardChildrensChildren: true).Append(currRoot.Element);
if (this.SelectedElement == null || this.SelectedElement.Root != currRoot) { if (this.SelectedElement?.Root != currRoot) {
return backward ? children.LastOrDefault(c => c.CanBeSelected) : children.FirstOrDefault(c => c.CanBeSelected); return backward ? children.LastOrDefault(c => c.CanBeSelected) : children.FirstOrDefault(c => c.CanBeSelected);
} else { } else {
var foundCurr = false; var foundCurr = false;