fix(term): prevent double keyboard input

Disconnects the "gui_input" signal as the _gui_input() override is
working as expected now. Having this signal connected was causing it to
be called twice for every input.
This commit is contained in:
Leroy Hopson 2024-02-25 22:06:58 +13:00
parent cf0beee0c1
commit 8cd11fdae6
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
2 changed files with 7 additions and 2 deletions

View file

@ -646,8 +646,6 @@ void Terminal::initialize_input() {
selection_timer->set_wait_time(0.05); selection_timer->set_wait_time(0.05);
selection_timer->connect("timeout", Callable(this, "_on_selection_held")); selection_timer->connect("timeout", Callable(this, "_on_selection_held"));
add_child(selection_timer, false, INTERNAL_MODE_FRONT); add_child(selection_timer, false, INTERNAL_MODE_FRONT);
connect("gui_input", Callable(this, "_on_gui_input"));
} }
void Terminal::_handle_key_input(Ref<InputEventKey> event) { void Terminal::_handle_key_input(Ref<InputEventKey> event) {

View file

@ -57,6 +57,13 @@ class TestKeyPressed:
await wait_for_signal(terminal.key_pressed, 1) await wait_for_signal(terminal.key_pressed, 1)
assert_signal_emitted(terminal, "key_pressed") assert_signal_emitted(terminal, "key_pressed")
func test_key_pressed_emitted_only_once_per_key_input():
input_event.keycode = KEY_B
input_event.unicode = "b".unicode_at(0)
await wait_for_signal(terminal.key_pressed, 1)
assert_signal_emit_count(terminal, "key_pressed", 1)
func test_key_pressed_emits_interpreted_key_input_as_first_param(): func test_key_pressed_emits_interpreted_key_input_as_first_param():
input_event.keycode = KEY_UP input_event.keycode = KEY_UP
input_event.unicode = 0 input_event.unicode = 0