diff --git a/Assets/Scripts/GameModeManager.cs b/Assets/Scripts/GameModeManager.cs
index 21f3113..269d228 100644
--- a/Assets/Scripts/GameModeManager.cs
+++ b/Assets/Scripts/GameModeManager.cs
@@ -347,6 +347,7 @@ public class GameModeManager : MonoBehaviour
private bool WasSwitchPressed()
{
+ if (TypingGuard.IsTyping) return false; // don't switch modes while typing in a text field
#if ENABLE_INPUT_SYSTEM
return Keyboard.current != null && Keyboard.current[switchKey].wasPressedThisFrame;
#else
diff --git a/Assets/Scripts/MeshPainter.Undo.cs b/Assets/Scripts/MeshPainter.Undo.cs
index 1d5df5a..1a04d6b 100644
--- a/Assets/Scripts/MeshPainter.Undo.cs
+++ b/Assets/Scripts/MeshPainter.Undo.cs
@@ -241,6 +241,7 @@ public partial class MeshPainter
{
undo = false;
redo = false;
+ if (TypingGuard.IsTyping) return; // let Ctrl+Z/Y edit text instead of the painting
#if ENABLE_INPUT_SYSTEM
var kb = Keyboard.current;
if (kb != null)
diff --git a/Assets/Scripts/NetworkBootstrap.cs b/Assets/Scripts/NetworkBootstrap.cs
index 6613f58..a894b5f 100644
--- a/Assets/Scripts/NetworkBootstrap.cs
+++ b/Assets/Scripts/NetworkBootstrap.cs
@@ -38,6 +38,7 @@ public class NetworkBootstrap : MonoBehaviour
private void Update()
{
if (!enableHotkeys) return;
+ if (TypingGuard.IsTyping) return; // don't fire H/C/J/K while typing in a text field
#if ENABLE_INPUT_SYSTEM
var kb = Keyboard.current;
if (kb == null || _net == null) return;
diff --git a/Assets/Scripts/PlayerPoseController.cs b/Assets/Scripts/PlayerPoseController.cs
index 4f1592a..77772cf 100644
--- a/Assets/Scripts/PlayerPoseController.cs
+++ b/Assets/Scripts/PlayerPoseController.cs
@@ -341,6 +341,7 @@ public class PlayerPoseController : MonoBehaviour
private bool CycleKeyPressed()
{
+ if (TypingGuard.IsTyping) return false; // don't cycle pose while typing in a text field
#if ENABLE_INPUT_SYSTEM
var keyboard = Keyboard.current;
return keyboard != null && keyboard[cycleKey].wasPressedThisFrame;
diff --git a/Assets/Scripts/TypingGuard.cs b/Assets/Scripts/TypingGuard.cs
new file mode 100644
index 0000000..e8c163e
--- /dev/null
+++ b/Assets/Scripts/TypingGuard.cs
@@ -0,0 +1,30 @@
+using UnityEngine.EventSystems;
+using TMPro;
+
+///
+/// True while the user is editing a focused on-screen text field (e.g. the paint HUD's
+/// "save as" name input). Global gameplay/dev hotkeys consult this so typing a name like
+/// "Checkers" doesn't also fire single-key shortcuts (C = cycle pose, K = shutdown,
+/// the mode-switch key, Ctrl+Z = undo, ...).
+///
+public static class TypingGuard
+{
+ /// A text input field is currently focused and capturing keystrokes.
+ public static bool IsTyping
+ {
+ get
+ {
+ var es = EventSystem.current;
+ if (!es) return false;
+
+ var go = es.currentSelectedGameObject;
+ if (!go) return false;
+
+ var tmp = go.GetComponent();
+ if (tmp) return tmp.isFocused;
+
+ var legacy = go.GetComponent();
+ return legacy && legacy.isFocused;
+ }
+ }
+}
diff --git a/Assets/Scripts/TypingGuard.cs.meta b/Assets/Scripts/TypingGuard.cs.meta
new file mode 100644
index 0000000..57a99c9
--- /dev/null
+++ b/Assets/Scripts/TypingGuard.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: c30f56f99c2725a4e861c19a5e83e0aa
\ No newline at end of file