diff options
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 8 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 11 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.h | 2 | ||||
-rw-r--r-- | editor/plugins/text_editor.cpp | 11 | ||||
-rw-r--r-- | editor/plugins/text_editor.h | 2 |
6 files changed, 27 insertions, 9 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 876ef3bae9..b292ad8620 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1734,7 +1734,7 @@ void ScriptEditor::ensure_select_current() { if (tab_container->get_tab_count() && tab_container->get_current_tab() >= 0) { ScriptEditorBase *se = _get_current_editor(); if (se) { - se->enable_editor(); + se->enable_editor(this); if (!grab_focus_block && is_visible_in_tree()) { se->ensure_focus(); @@ -2108,7 +2108,7 @@ void ScriptEditor::_update_script_names() { ScriptEditorBase *se = _get_current_editor(); if (se) { - se->enable_editor(); + se->enable_editor(this); _update_selected_editor_menu(); } } @@ -2273,7 +2273,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, if ((scr != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) { if (should_open) { - se->enable_editor(); + se->enable_editor(this); if (tab_container->get_current_tab() != i) { _go_to_tab(i); @@ -2329,7 +2329,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, tab_container->add_child(se); if (p_grab_focus) { - se->enable_editor(); + se->enable_editor(this); } // If we delete a script within the filesystem, the original resource path diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index e69b8f8f82..a45ce4cc22 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -139,7 +139,7 @@ public: virtual Ref<Resource> get_edited_resource() const = 0; virtual Vector<String> get_functions() = 0; virtual void set_edited_resource(const Ref<Resource> &p_res) = 0; - virtual void enable_editor() = 0; + virtual void enable_editor(Control *p_shortcut_context = nullptr) = 0; virtual void reload_text() = 0; virtual String get_name() = 0; virtual Ref<Texture2D> get_theme_icon() = 0; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 7d7ef9245f..e54a338c09 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -151,7 +151,7 @@ void ScriptTextEditor::set_edited_resource(const Ref<Resource> &p_res) { code_editor->update_line_and_column(); } -void ScriptTextEditor::enable_editor() { +void ScriptTextEditor::enable_editor(Control *p_shortcut_context) { if (editor_enabled) { return; } @@ -161,6 +161,15 @@ void ScriptTextEditor::enable_editor() { _enable_code_editor(); _validate_script(); + + if (p_shortcut_context) { + for (int i = 0; i < edit_hb->get_child_count(); ++i) { + Control *c = cast_to<Control>(edit_hb->get_child(i)); + if (c) { + c->set_shortcut_context(p_shortcut_context); + } + } + } } void ScriptTextEditor::_load_theme_settings() { diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index c165295a8e..5fd12674b3 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -206,7 +206,7 @@ public: virtual void apply_code() override; virtual Ref<Resource> get_edited_resource() const override; virtual void set_edited_resource(const Ref<Resource> &p_res) override; - virtual void enable_editor() override; + virtual void enable_editor(Control *p_shortcut_context = nullptr) override; virtual Vector<String> get_functions() override; virtual void reload_text() override; virtual String get_name() override; diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 07f0819c7f..0c12b03447 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -108,7 +108,7 @@ void TextEditor::set_edited_resource(const Ref<Resource> &p_res) { code_editor->update_line_and_column(); } -void TextEditor::enable_editor() { +void TextEditor::enable_editor(Control *p_shortcut_context) { if (editor_enabled) { return; } @@ -116,6 +116,15 @@ void TextEditor::enable_editor() { editor_enabled = true; _load_theme_settings(); + + if (p_shortcut_context) { + for (int i = 0; i < edit_hb->get_child_count(); ++i) { + Control *c = cast_to<Control>(edit_hb->get_child(i)); + if (c) { + c->set_shortcut_context(p_shortcut_context); + } + } + } } void TextEditor::add_callback(const String &p_function, PackedStringArray p_args) { diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index a7a640247f..486a0f2c23 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -111,7 +111,7 @@ public: virtual Ref<Texture2D> get_theme_icon() override; virtual Ref<Resource> get_edited_resource() const override; virtual void set_edited_resource(const Ref<Resource> &p_res) override; - virtual void enable_editor() override; + virtual void enable_editor(Control *p_shortcut_context = nullptr) override; virtual void reload_text() override; virtual void apply_code() override; virtual bool is_unsaved() override; |