Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BetterStats] When filter input is focused and you press ENTER or ESC we should focus on Production panel #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion BetterStats/BetterStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using UnityEngine;
using UnityEngine.UI;
using System.Globalization;
using UnityEngine.EventSystems;

namespace BetterStats
{
Expand Down Expand Up @@ -440,10 +441,24 @@ public static void UIStatisticsWindow__OnOpen_Postfix(UIStatisticsWindow __insta

_inputField.onValueChanged.AddListener((string value) =>
{
filterStr = value;
if (_inputField.wasCanceled)
{
// When escape key is pressed keep the current value. The default behavior was to reset/restore value to the previous submitted text
_inputField.text = filterStr;
}
else
{
filterStr = value;
}
__instance.ComputeDisplayEntries();
});

_inputField.onEndEdit.AddListener((string value) =>
{
// Reset focus to allow pressing escape key to close production panel after entering value into filter inputField
EventSystem.current.SetSelectedGameObject(null);
});

chxGO.transform.SetParent(__instance.productSortBox.transform.parent, false);
txtGO.transform.SetParent(chxGO.transform, false);
filterGO.transform.SetParent(__instance.productSortBox.transform.parent, false);
Expand Down