Skip to content

Commit 3a08eab

Browse files
committed
Whitelist the Tab key from the filter
1 parent 1b21f88 commit 3a08eab

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

BepInEx.InputHotkeyBlock/InputHotkeyBlock.cs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,16 @@ internal void Main()
3131
private static GameObject previousSelectedGameObject;
3232
private static bool previousState;
3333

34+
private static bool inhibit;
35+
3436
/// <summary>
3537
/// Check if an input field is selected
3638
/// </summary>
3739
private static bool AllowInput()
3840
{
41+
if (inhibit)
42+
return true;
43+
3944
//UI elements from some mods
4045
if (GUIUtility.keyboardControl > 0)
4146
return false;
@@ -44,20 +49,22 @@ private static bool AllowInput()
4449
if (currentSelectedGameObject != null)
4550
{
4651
// Buffer results to prevent unnecessary GetComponent calls
47-
if (currentSelectedGameObject == previousSelectedGameObject)
52+
if (currentSelectedGameObject == previousSelectedGameObject)
53+
{
54+
if (IsWhitelistedKey()) return true;
4855
return previousState;
56+
}
4957

5058
previousSelectedGameObject = currentSelectedGameObject;
51-
previousState = false;
5259

53-
//TextMeshPro InputField
54-
if (TMPInputFieldType != null)
55-
if (currentSelectedGameObject.GetComponent(TMPInputFieldType) != null)
56-
return false;
60+
if (currentSelectedGameObject.GetComponent<InputField>() != null ||
61+
TMPInputFieldType != null && currentSelectedGameObject.GetComponent(TMPInputFieldType) != null)
62+
{
63+
previousState = false;
5764

58-
//Other InputFields
59-
if (currentSelectedGameObject.GetComponent<InputField>() != null)
65+
if (IsWhitelistedKey()) return true;
6066
return false;
67+
}
6168
}
6269
else
6370
{
@@ -68,6 +75,14 @@ private static bool AllowInput()
6875
return true;
6976
}
7077

78+
private static bool IsWhitelistedKey()
79+
{
80+
inhibit = true;
81+
var isWhitelistedKey = Input.GetKey(KeyCode.Tab);
82+
inhibit = false;
83+
return isWhitelistedKey;
84+
}
85+
7186
/// <summary>
7287
/// GetKey hooks. When HotkeyBlock returns false the GetKey functions will be prevented from running.
7388
/// </summary>

0 commit comments

Comments
 (0)