fix: keep Android keyboard sessions open

This commit is contained in:
Voyager 2026-08-16 23:04:07 -04:00
parent 80c570657b
commit d8c8886216
2 changed files with 8 additions and 19 deletions

View file

@ -299,16 +299,22 @@ func _validate_native_keyboard() -> void:
character_event.unicode = 97 character_event.unicode = 97
character_event.pressed = true character_event.pressed = true
keyboard.call("_input", character_event) keyboard.call("_input", character_event)
outside_button.grab_focus()
await process_frame await process_frame
assert(edit.has_focus()) assert(edit.has_focus())
outside_button.grab_focus()
await process_frame
assert(outside_button.has_focus())
edit.grab_focus()
var backspace_event := InputEventKey.new() var backspace_event := InputEventKey.new()
backspace_event.keycode = KEY_BACKSPACE backspace_event.keycode = KEY_BACKSPACE
backspace_event.pressed = true backspace_event.pressed = true
keyboard.call("_input", backspace_event) keyboard.call("_input", backspace_event)
outside_button.grab_focus()
await process_frame await process_frame
assert(edit.has_focus()) assert(edit.has_focus())
outside_button.grab_focus()
await process_frame
assert(outside_button.has_focus())
edit.grab_focus()
var close_event := InputEventJoypadButton.new() var close_event := InputEventJoypadButton.new()
close_event.button_index = JOY_BUTTON_B close_event.button_index = JOY_BUTTON_B
close_event.pressed = true close_event.pressed = true

View file

@ -306,9 +306,6 @@ func _handle_native_keyboard_input(event: InputEvent) -> void:
return return
if key_event.keycode in [KEY_ENTER, KEY_KP_ENTER]: if key_event.keycode in [KEY_ENTER, KEY_KP_ENTER]:
return return
# Android delivers IME edits after this input phase. Reassert the same field
# afterward in case a page refresh tried to move focus while its text changed.
_preserve_native_text_focus.call_deferred(focused)
func _open_native_keyboard_for(control: Control) -> void: func _open_native_keyboard_for(control: Control) -> void:
@ -326,20 +323,6 @@ func _close_native_keyboard(control: Control) -> void:
DisplayServer.virtual_keyboard_hide() DisplayServer.virtual_keyboard_hide()
func _preserve_native_text_focus(control: Control) -> void:
if (
not _uses_native_virtual_keyboard()
or not is_instance_valid(control)
or not _can_edit(control)
or not control.is_inside_tree()
or not control.is_visible_in_tree()
or not bool(control.get("virtual_keyboard_enabled"))
):
return
if not control.has_focus():
control.grab_focus()
func _can_edit(control: Control) -> bool: func _can_edit(control: Control) -> bool:
if ( if (
control == null control == null