mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-25 02:30:27 +01:00
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:
parent
cf0beee0c1
commit
8cd11fdae6
2 changed files with 7 additions and 2 deletions
|
@ -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) {
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue