Skip to content

Commit

Permalink
Automatically select the first element when a dropdown is opened in a…
Browse files Browse the repository at this point in the history
…uto nav mode
  • Loading branch information
Ellpeck committed Mar 10, 2022
1 parent 67388c1 commit cb8fed8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Improvements
- Automatically update all elements when changing a ui system's viewport
- Allow setting a default color for clickable links in UiStyle
- Allow ElementHelper's KeybindButton to query a combination at a given index
- Automatically select the first element when a dropdown is opened in auto nav mode

Fixes
- Fixed paragraph links having incorrect hover locations when using special text alignments
Expand Down
7 changes: 7 additions & 0 deletions MLEM.Ui/Elements/Dropdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public class Dropdown : Button {
set {
this.Panel.IsHidden = !value;
this.OnOpenedOrClosed?.Invoke(this);

// select the first dropdown element in auto nav mode
if (value && this.Controls.IsAutoNavMode) {
var firstChild = this.Panel.GetChildren().FirstOrDefault(c => c.CanBeSelected);
if (firstChild != null)
this.Root.SelectElement(firstChild, true);
}
}
}
/// <summary>
Expand Down

0 comments on commit cb8fed8

Please sign in to comment.