diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-05-03 09:51:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 09:51:57 +0200 |
commit | d9628204533348552fb18c3f28f7b088cb846ca0 (patch) | |
tree | ac49811a37cfd1f69418a9e3bbc85a6514f77fc6 | |
parent | f1e39e1fc885973360519a533f9748f1ac158f86 (diff) | |
parent | 39398f173e458a11c1b7ad7a21d69f3895967917 (diff) |
Merge pull request #28620 from megalike/fix_mac_os_move_cursor
Fix Mac OS move cursor behaviour
-rw-r--r-- | scene/gui/text_edit.cpp | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 9ab30b1976..ec714dc8a3 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2275,6 +2275,30 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { 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 move_cursor_key = KEY_UNKNOWN; + switch (k->get_scancode()) { + case KEY_F: { + move_cursor_key = KEY_RIGHT; + } break; + case KEY_B: { + move_cursor_key = KEY_LEFT; + } break; + case KEY_P: { + move_cursor_key = KEY_UP; + } break; + case KEY_N: { + move_cursor_key = KEY_DOWN; + } break; + } + + if (move_cursor_key != KEY_UNKNOWN) { + k->set_scancode(move_cursor_key); + k->set_control(false); + } + } +#endif _reset_caret_blink_timer(); @@ -2596,15 +2620,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } FALLTHROUGH; } -#ifdef APPLE_STYLE_KEYS - case KEY_B: { - if (!k->get_control()) { - scancode_handled = false; - break; - } - FALLTHROUGH; - } -#endif case KEY_LEFT: { if (k->get_shift()) @@ -2681,15 +2696,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } FALLTHROUGH; } -#ifdef APPLE_STYLE_KEYS - case KEY_F: { - if (!k->get_control()) { - scancode_handled = false; - break; - } - FALLTHROUGH; - } -#endif case KEY_RIGHT: { if (k->get_shift()) @@ -2751,15 +2757,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } FALLTHROUGH; } -#ifdef APPLE_STYLE_KEYS - case KEY_P: { - if (!k->get_control()) { - scancode_handled = false; - break; - } - FALLTHROUGH; - } -#endif case KEY_UP: { if (k->get_alt()) { @@ -2813,15 +2810,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } FALLTHROUGH; } -#ifdef APPLE_STYLE_KEYS - case KEY_N: { - if (!k->get_control()) { - scancode_handled = false; - break; - } - FALLTHROUGH; - } -#endif case KEY_DOWN: { if (k->get_alt()) { |