1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-25 01:39:23 +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
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;