diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-03-01 23:00:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-01 23:00:42 +0100 |
commit | e2b66cacf78ae39b94df748e9740b98a1f011e77 (patch) | |
tree | 56d468d762c43879c20b342702e8fc999221e6c6 /scene/gui/text_edit.cpp | |
parent | 55396d6e06f8e4e355e9ab0595bdb7f27c1c36dd (diff) | |
parent | 1af06d3d4608b17c74caed951cd9579ccbba229d (diff) |
Merge pull request #18020 from bruvzg/input_fix_non_latin_and_add_hw_scancodes
Fix non-latin layout scancodes on Linux, adds access to physical scancodes.
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r-- | scene/gui/text_edit.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 86002ed2c4..5e925bf37f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2564,9 +2564,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { k = k->duplicate(); // It will be modified later on. #ifdef OSX_ENABLED - if (k->get_scancode() == KEY_META) { + if (k->get_keycode() == KEY_META) { #else - if (k->get_scancode() == KEY_CONTROL) { + if (k->get_keycode() == KEY_CONTROL) { #endif if (select_identifiers_enabled) { @@ -2597,7 +2597,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (valid) { if (!k->get_alt()) { - if (k->get_scancode() == KEY_UP) { + if (k->get_keycode() == KEY_UP) { if (completion_index > 0) { completion_index--; @@ -2611,7 +2611,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_DOWN) { + if (k->get_keycode() == KEY_DOWN) { if (completion_index < completion_options.size() - 1) { completion_index++; @@ -2625,7 +2625,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_PAGEUP) { + if (k->get_keycode() == KEY_PAGEUP) { completion_index -= get_constant("completion_lines"); if (completion_index < 0) @@ -2636,7 +2636,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_PAGEDOWN) { + if (k->get_keycode() == KEY_PAGEDOWN) { completion_index += get_constant("completion_lines"); if (completion_index >= completion_options.size()) @@ -2647,7 +2647,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_HOME && completion_index > 0) { + if (k->get_keycode() == KEY_HOME && completion_index > 0) { completion_index = 0; completion_current = completion_options[completion_index]; @@ -2656,7 +2656,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_END && completion_index < completion_options.size() - 1) { + if (k->get_keycode() == KEY_END && completion_index < completion_options.size() - 1) { completion_index = completion_options.size() - 1; completion_current = completion_options[completion_index]; @@ -2665,14 +2665,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_KP_ENTER || k->get_scancode() == KEY_ENTER || k->get_scancode() == KEY_TAB) { + if (k->get_keycode() == KEY_KP_ENTER || k->get_keycode() == KEY_ENTER || k->get_keycode() == KEY_TAB) { _confirm_completion(); accept_event(); return; } - if (k->get_scancode() == KEY_BACKSPACE) { + if (k->get_keycode() == KEY_BACKSPACE) { _reset_caret_blink_timer(); @@ -2682,7 +2682,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_SHIFT) { + if (k->get_keycode() == KEY_SHIFT) { accept_event(); return; } @@ -2726,20 +2726,20 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { /* TEST CONTROL FIRST! */ // Some remaps for duplicate functions. - if (k->get_command() && !k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_scancode() == KEY_INSERT) { + if (k->get_command() && !k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_keycode() == KEY_INSERT) { - k->set_scancode(KEY_C); + k->set_keycode(KEY_C); } - if (!k->get_command() && k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_scancode() == KEY_INSERT) { + if (!k->get_command() && k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_keycode() == KEY_INSERT) { - k->set_scancode(KEY_V); + k->set_keycode(KEY_V); k->set_command(true); k->set_shift(false); } #ifdef APPLE_STYLE_KEYS if (k->get_control() && !k->get_shift() && !k->get_alt() && !k->get_command()) { uint32_t remap_key = KEY_UNKNOWN; - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_F: { remap_key = KEY_RIGHT; } break; @@ -2761,7 +2761,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } if (remap_key != KEY_UNKNOWN) { - k->set_scancode(remap_key); + k->set_keycode(remap_key); k->set_control(false); } } @@ -2779,7 +2779,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { bool unselect = false; bool dobreak = false; - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_TAB: { if (k->get_shift()) { @@ -2853,11 +2853,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { selection.selecting_text = false; - bool scancode_handled = true; + bool keycode_handled = true; - // Special scancode test. + // Special keycode test. - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_KP_ENTER: case KEY_ENTER: { @@ -2979,7 +2979,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { completion_hint = ""; update(); } else { - scancode_handled = false; + keycode_handled = false; } } break; case KEY_TAB: { @@ -3052,7 +3052,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (k->get_alt() && cursor.column > 1) { #else if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } else if (k->get_command() && cursor.column > 1) { #endif @@ -3109,7 +3109,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_4: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3145,7 +3145,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } else if (k->get_alt()) { #else if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } else if (k->get_command()) { #endif @@ -3185,7 +3185,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_6: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3207,7 +3207,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } else if (k->get_alt()) { #else if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } else if (k->get_command()) { #endif @@ -3246,7 +3246,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_8: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3254,7 +3254,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { case KEY_UP: { if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } #ifndef APPLE_STYLE_KEYS @@ -3299,7 +3299,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_2: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3307,7 +3307,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { case KEY_DOWN: { if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } #ifndef APPLE_STYLE_KEYS @@ -3367,7 +3367,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (k->get_alt() && cursor.column < curline_len - 1) { #else if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } else if (k->get_command() && cursor.column < curline_len - 1) { #endif @@ -3422,7 +3422,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_7: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3483,7 +3483,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_1: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3530,7 +3530,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_9: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3553,7 +3553,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_3: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3578,7 +3578,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { #ifndef APPLE_STYLE_KEYS if (!k->get_control() || k->get_shift() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } if (is_shortcut_keys_enabled()) { @@ -3586,7 +3586,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } #else if ((!k->get_command() && !k->get_control())) { - scancode_handled = false; + keycode_handled = false; break; } if (!k->get_shift() && k->get_command() && is_shortcut_keys_enabled()) @@ -3617,7 +3617,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { case KEY_E: { if (!k->get_control() || k->get_command() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3642,7 +3642,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { break; } if (!k->get_command() || k->get_shift() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } if (is_shortcut_keys_enabled()) { @@ -3653,7 +3653,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { case KEY_C: { if (!k->get_command() || k->get_shift() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3669,7 +3669,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } if (!k->get_command()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3687,7 +3687,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } if (!k->get_command()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3700,7 +3700,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { break; } if (!k->get_command() || k->get_shift() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3717,9 +3717,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { #endif query_code_comple(); - scancode_handled = true; + keycode_handled = true; } else { - scancode_handled = false; + keycode_handled = false; } } break; @@ -3736,20 +3736,20 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { default: { - scancode_handled = false; + keycode_handled = false; } break; } - if (scancode_handled) + if (keycode_handled) accept_event(); - if (k->get_scancode() == KEY_INSERT) { + if (k->get_keycode() == KEY_INSERT) { set_insert_mode(!insert_mode); accept_event(); return; } - if (!scancode_handled && !k->get_command()) { // For German keyboards. + if (!keycode_handled && !k->get_command()) { // For German keyboards. if (k->get_unicode() >= 32) { |