Skip to content

Commit fbf92c9

Browse files
Let text inputs handle printable key events before our custom input system (#6880)
* Let text inputs handle printable key events * Explain text input shortcut bypass * Add clarification comment on why focus owner check is implemented --------- Co-authored-by: Henri Hyyryläinen <henri.hyyrylainen@gmail.com>
1 parent 3392df9 commit fbf92c9

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/engine/input/InputManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ public override void _Input(InputEvent @event)
358358
if (PerformingRebind)
359359
return;
360360

361+
if (FocusedTextInputShouldHandle(@event))
362+
return;
363+
361364
OnInput(false, @event);
362365
}
363366

@@ -479,6 +482,19 @@ private static void PrintConsumeAttemptDelayedError(MethodBase method)
479482
method.DeclaringType?.Name ?? "global", ".", method.Name);
480483
}
481484

485+
private bool FocusedTextInputShouldHandle(InputEvent @event)
486+
{
487+
if (@event is not InputEventKey { Pressed: true } keyEvent)
488+
return false;
489+
490+
if (keyEvent.Unicode < ' ')
491+
return false;
492+
493+
// Let focused text fields handle printable keys first, so layout-specific typing is not consumed as a shortcut.
494+
// See: https://github.com/Revolutionary-Games/Thrive/issues/3031
495+
return GetViewport().GuiGetFocusOwner() is LineEdit or TextEdit;
496+
}
497+
482498
/// <summary>
483499
/// Performs post load actions for inputs. For example some inputs need to listen for settings changes
484500
/// </summary>

0 commit comments

Comments
 (0)