From 97d355c13dc8fbfd8f6b1c507e20926502a6ace1 Mon Sep 17 00:00:00 2001 From: M4rYu5 <30922014+M4rYu5@users.noreply.github.com> Date: Sat, 11 Feb 2023 07:03:25 +0200 Subject: [PATCH] Now, in editor, CapsLock behave like a modifier key: does nothing when pressed alone. Before, it ended up closing the code completion, and rerendering portions of editor. --- scene/gui/code_edit.cpp | 6 +++--- scene/gui/text_edit.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index b084cb5bea..036a99ae6c 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -436,12 +436,12 @@ void CodeEdit::gui_input(const Ref &p_gui_input) { } /* If a modifier has been pressed, and nothing else, return. */ - if (!k->is_pressed() || k->get_keycode() == Key::CTRL || k->get_keycode() == Key::ALT || k->get_keycode() == Key::SHIFT || k->get_keycode() == Key::META) { + if (!k->is_pressed() || k->get_keycode() == Key::CTRL || k->get_keycode() == Key::ALT || k->get_keycode() == Key::SHIFT || k->get_keycode() == Key::META || k->get_keycode() == Key::CAPSLOCK) { return; } - /* Allow unicode handling if: */ - /* No Modifiers are pressed (except shift) */ + // Allow unicode handling if: + // No modifiers are pressed (except Shift and CapsLock) bool allow_unicode_handling = !(k->is_command_or_control_pressed() || k->is_ctrl_pressed() || k->is_alt_pressed() || k->is_meta_pressed()); /* AUTO-COMPLETE */ diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index d785280701..17e712b24d 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2000,14 +2000,14 @@ void TextEdit::gui_input(const Ref &p_gui_input) { } // If a modifier has been pressed, and nothing else, return. - if (k->get_keycode() == Key::CTRL || k->get_keycode() == Key::ALT || k->get_keycode() == Key::SHIFT || k->get_keycode() == Key::META) { + if (k->get_keycode() == Key::CTRL || k->get_keycode() == Key::ALT || k->get_keycode() == Key::SHIFT || k->get_keycode() == Key::META || k->get_keycode() == Key::CAPSLOCK) { return; } _reset_caret_blink_timer(); // Allow unicode handling if: - // * No Modifiers are pressed (except shift) + // * No modifiers are pressed (except Shift and CapsLock) bool allow_unicode_handling = !(k->is_command_or_control_pressed() || k->is_ctrl_pressed() || k->is_alt_pressed() || k->is_meta_pressed()); // Check and handle all built in shortcuts.