diff --git a/BetterStats/BetterStats.cs b/BetterStats/BetterStats.cs index 9f75253..15eba13 100644 --- a/BetterStats/BetterStats.cs +++ b/BetterStats/BetterStats.cs @@ -6,6 +6,7 @@ using UnityEngine; using UnityEngine.UI; using System.Globalization; +using UnityEngine.EventSystems; namespace BetterStats { @@ -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);