From 49714b09635fddb3dbada703017482e732a4b459 Mon Sep 17 00:00:00 2001 From: Eric M Date: Mon, 7 Dec 2020 21:32:00 +1000 Subject: [PATCH] Removed hardcoded shortcuts from /scene and converted to input actions This removes hardcoded actions from things like LineEdit and TextEdit. Previously, things like copy, paste, etc were all hardcoded to Ctrl+C, Ctrl+V, etc. They could not be changed. This allows the possibility of them being changed, by making them use the action map. This has the added benefit of greatly simplifying the input handling logic in those controls. The logic which was previously in a huge and hard to follow switch statement has been extracted to individual methods. --- core/input/input_map.cpp | 4 + editor/editor_node.cpp | 4 +- editor/plugins/script_text_editor.cpp | 38 +- editor/plugins/shader_editor_plugin.cpp | 30 +- editor/plugins/text_editor.cpp | 28 +- editor/settings_config_dialog.cpp | 4 +- .../visual_script/visual_script_editor.cpp | 12 +- scene/gui/graph_edit.cpp | 18 +- scene/gui/line_edit.cpp | 801 +++--- scene/gui/line_edit.h | 9 + scene/gui/rich_text_label.cpp | 73 +- scene/gui/text_edit.cpp | 2156 ++++++++--------- scene/gui/text_edit.h | 25 +- 13 files changed, 1467 insertions(+), 1735 deletions(-) diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 1e8d3ef7d3..b31c431ead 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -443,6 +443,10 @@ const OrderedHashMap>> &InputMap::get_builtins() { inputs.push_back(InputEventKey::create_reference(KEY_SPACE | KEY_MASK_CMD)); default_builtin_cache.insert("ui_text_completion_query", inputs); + inputs = List>(); + inputs.push_back(InputEventKey::create_reference(KEY_TAB)); + default_builtin_cache.insert("ui_text_completion_accept", inputs); + // Newlines inputs = List>(); inputs.push_back(InputEventKey::create_reference(KEY_ENTER)); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index cdbc4a0de9..8c03552981 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6215,8 +6215,8 @@ EditorNode::EditorNode() { pm_export->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); p->add_separator(); - p->add_shortcut(ED_SHORTCUT("editor/undo", TTR("Undo"), KEY_MASK_CMD + KEY_Z), EDIT_UNDO, true); - p->add_shortcut(ED_SHORTCUT("editor/redo", TTR("Redo"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_Z), EDIT_REDO, true); + p->add_shortcut(ED_GET_SHORTCUT("ui_undo"), EDIT_UNDO, true); + p->add_shortcut(ED_GET_SHORTCUT("ui_redo"), EDIT_REDO, true); p->add_separator(); p->add_shortcut(ED_SHORTCUT("editor/reload_saved_scene", TTR("Reload Saved Scene")), EDIT_RELOAD_SAVED_SCENE); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 71b18497b0..b6df66b8af 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1066,7 +1066,7 @@ void ScriptTextEditor::_edit_option(int p_op) { return; } - tx->indent_left(); + tx->indent_selected_lines_left(); } break; case EDIT_INDENT_RIGHT: { Ref