diff --git a/tests/on_screen_keyboard_validation.gd b/tests/on_screen_keyboard_validation.gd index 5454a65..cbfb369 100644 --- a/tests/on_screen_keyboard_validation.gd +++ b/tests/on_screen_keyboard_validation.gd @@ -299,16 +299,22 @@ func _validate_native_keyboard() -> void: character_event.unicode = 97 character_event.pressed = true keyboard.call("_input", character_event) - outside_button.grab_focus() await process_frame assert(edit.has_focus()) + outside_button.grab_focus() + await process_frame + assert(outside_button.has_focus()) + edit.grab_focus() var backspace_event := InputEventKey.new() backspace_event.keycode = KEY_BACKSPACE backspace_event.pressed = true keyboard.call("_input", backspace_event) - outside_button.grab_focus() await process_frame assert(edit.has_focus()) + outside_button.grab_focus() + await process_frame + assert(outside_button.has_focus()) + edit.grab_focus() var close_event := InputEventJoypadButton.new() close_event.button_index = JOY_BUTTON_B close_event.pressed = true diff --git a/ui/on_screen_keyboard.gd b/ui/on_screen_keyboard.gd index 8c2122d..e961f08 100644 --- a/ui/on_screen_keyboard.gd +++ b/ui/on_screen_keyboard.gd @@ -306,9 +306,6 @@ func _handle_native_keyboard_input(event: InputEvent) -> void: return if key_event.keycode in [KEY_ENTER, KEY_KP_ENTER]: 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: @@ -326,20 +323,6 @@ func _close_native_keyboard(control: Control) -> void: 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: if ( control == null