From c5b2b8798e3e8fc35944dcf685170a261ecc07aa Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 17 Mar 2022 20:46:49 +0100 Subject: [PATCH] Fixed dropdowns with some non-selectable children failing to navigate when using gamepad controls --- CHANGELOG.md | 1 + MLEM.Ui/Elements/Dropdown.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdd681c..2c9ce6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ Fixes - Fixed buttons and checkboxes changing their CanBeSelected and CanBePressed values when being disabled - Fixed children of Panel scroll bars also being scrolled - Fixed RootElement.CanSelectContent and Element.IsSelected returning incorrect results when CanBeSelected changes +- Fixed dropdowns with some non-selectable children failing to navigate when using gamepad controls Removals - Marked StyleProp equality members as obsolete diff --git a/MLEM.Ui/Elements/Dropdown.cs b/MLEM.Ui/Elements/Dropdown.cs index eec0813..8f4f25e 100644 --- a/MLEM.Ui/Elements/Dropdown.cs +++ b/MLEM.Ui/Elements/Dropdown.cs @@ -63,10 +63,10 @@ namespace MLEM.Ui.Elements { if (dir == Direction2.Left || dir == Direction2.Right) return null; if (dir == Direction2.Up) { - var prev = element.GetOlderSibling(); + var prev = element.GetOlderSibling(e => e.CanBeSelected); return prev ?? this; } else if (dir == Direction2.Down) { - return element.GetSiblings(e => e.GetOlderSibling() == element).FirstOrDefault(); + return element.GetSiblings(e => e.CanBeSelected && e.GetOlderSibling(s => s.CanBeSelected) == element).FirstOrDefault(); } return usualNext; };