diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-11-26 10:42:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-26 10:42:06 +0100 |
commit | 1b9fb5c96936a141887b827cf0dfe850d4b04707 (patch) | |
tree | ede1fcd49c1f77dea9d07086023daf777a57a93a /platform | |
parent | 4813abc6e7168e8fdc6c30c23f9c26fb0a2d00af (diff) | |
parent | 63e2db249901312f317c45df8dffbf06e43b3c4a (diff) |
Merge pull request #55342 from Faless/js/4.x_input_fix_focus_iframe
Diffstat (limited to 'platform')
-rw-r--r-- | platform/javascript/js/libs/library_godot_input.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/platform/javascript/js/libs/library_godot_input.js b/platform/javascript/js/libs/library_godot_input.js index d85d0d5335..3c1c05e44e 100644 --- a/platform/javascript/js/libs/library_godot_input.js +++ b/platform/javascript/js/libs/library_godot_input.js @@ -393,7 +393,9 @@ const GodotInput = { const rect = canvas.getBoundingClientRect(); const pos = GodotInput.computePosition(evt, rect); const modifiers = GodotInput.getModifiers(evt); - if (p_pressed && document.activeElement !== GodotConfig.canvas) { + // Since the event is consumed, focus manually. + // NOTE: The iframe container may not have focus yet, so focus even when already active. + if (p_pressed) { GodotConfig.canvas.focus(); } if (func(p_pressed, evt.button, pos[0], pos[1], modifiers)) { @@ -412,7 +414,9 @@ const GodotInput = { const func = GodotRuntime.get_func(callback); const canvas = GodotConfig.canvas; function touch_cb(type, evt) { - if (type === 0 && document.activeElement !== GodotConfig.canvas) { + // Since the event is consumed, focus manually. + // NOTE: The iframe container may not have focus yet, so focus even when already active. + if (type === 0) { GodotConfig.canvas.focus(); } const rect = canvas.getBoundingClientRect(); |