Skip to content

Commit

Permalink
made sure PopupInput will be reselected after Popup gets closed even …
Browse files Browse the repository at this point in the history
…if opened by mouse
  • Loading branch information
TAImatem committed Jul 14, 2020
1 parent 4b7f678 commit 4dfbe42
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions OWML.ModHelper.Menus/ModComboInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private void UpdateLayout(string currentCombination)

protected override void Open()
{
base.Open();
InputMenu.Title = Menu is IModConfigMenu menu ? $"{menu.Title}.{Title}" : Title;
InputMenu.FillMenu(_combination);
InputMenu.OnConfirm += OnConfirm;
Expand Down
1 change: 1 addition & 0 deletions OWML.ModHelper.Menus/ModNumberInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public ModNumberInput(TwoButtonToggleElement element, IModMenu menu, IModInputMe

protected override void Open()
{
base.Open();
InputMenu.OnConfirm += OnConfirm;
InputMenu.OnCancel += OnCancel;
InputMenu.Open(InputType.Number, Value.ToString());
Expand Down
7 changes: 5 additions & 2 deletions OWML.ModHelper.Menus/ModPopupInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using OWML.ModHelper.Input;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

namespace OWML.ModHelper.Menus
{
Expand Down Expand Up @@ -61,7 +62,9 @@ protected virtual void OnOpenCommand(SingleAxisCommand command)
}
}

protected abstract void Open();

protected virtual void Open()
{
EventSystem.current.SetSelectedGameObject(ToggleElement.gameObject); // make sure it gets selected after popup closes
}
}
}
1 change: 1 addition & 0 deletions OWML.ModHelper.Menus/ModTextInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public ModTextInput(TwoButtonToggleElement element, IModMenu menu, IModInputMenu

protected override void Open()
{
base.Open();
InputMenu.OnConfirm += OnConfirm;
InputMenu.OnCancel += OnCancel;
InputMenu.Open(InputType.Text, Value);
Expand Down

0 comments on commit 4dfbe42

Please sign in to comment.