Set the shortcut context for the edit/search/goto menus to the ScriptEditor so that shortcuts continue to work when FindReplaceBar is focused.
This commit is contained in:
parent
4546986d21
commit
d499071e5b
@ -1734,7 +1734,7 @@ void ScriptEditor::ensure_select_current() {
|
|||||||
if (tab_container->get_tab_count() && tab_container->get_current_tab() >= 0) {
|
if (tab_container->get_tab_count() && tab_container->get_current_tab() >= 0) {
|
||||||
ScriptEditorBase *se = _get_current_editor();
|
ScriptEditorBase *se = _get_current_editor();
|
||||||
if (se) {
|
if (se) {
|
||||||
se->enable_editor();
|
se->enable_editor(this);
|
||||||
|
|
||||||
if (!grab_focus_block && is_visible_in_tree()) {
|
if (!grab_focus_block && is_visible_in_tree()) {
|
||||||
se->ensure_focus();
|
se->ensure_focus();
|
||||||
@ -2108,7 +2108,7 @@ void ScriptEditor::_update_script_names() {
|
|||||||
|
|
||||||
ScriptEditorBase *se = _get_current_editor();
|
ScriptEditorBase *se = _get_current_editor();
|
||||||
if (se) {
|
if (se) {
|
||||||
se->enable_editor();
|
se->enable_editor(this);
|
||||||
_update_selected_editor_menu();
|
_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 ((scr != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) {
|
||||||
if (should_open) {
|
if (should_open) {
|
||||||
se->enable_editor();
|
se->enable_editor(this);
|
||||||
|
|
||||||
if (tab_container->get_current_tab() != i) {
|
if (tab_container->get_current_tab() != i) {
|
||||||
_go_to_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);
|
tab_container->add_child(se);
|
||||||
|
|
||||||
if (p_grab_focus) {
|
if (p_grab_focus) {
|
||||||
se->enable_editor();
|
se->enable_editor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we delete a script within the filesystem, the original resource path
|
// If we delete a script within the filesystem, the original resource path
|
||||||
|
@ -139,7 +139,7 @@ public:
|
|||||||
virtual Ref<Resource> get_edited_resource() const = 0;
|
virtual Ref<Resource> get_edited_resource() const = 0;
|
||||||
virtual Vector<String> get_functions() = 0;
|
virtual Vector<String> get_functions() = 0;
|
||||||
virtual void set_edited_resource(const Ref<Resource> &p_res) = 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 void reload_text() = 0;
|
||||||
virtual String get_name() = 0;
|
virtual String get_name() = 0;
|
||||||
virtual Ref<Texture2D> get_theme_icon() = 0;
|
virtual Ref<Texture2D> get_theme_icon() = 0;
|
||||||
|
@ -151,7 +151,7 @@ void ScriptTextEditor::set_edited_resource(const Ref<Resource> &p_res) {
|
|||||||
code_editor->update_line_and_column();
|
code_editor->update_line_and_column();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptTextEditor::enable_editor() {
|
void ScriptTextEditor::enable_editor(Control *p_shortcut_context) {
|
||||||
if (editor_enabled) {
|
if (editor_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -161,6 +161,15 @@ void ScriptTextEditor::enable_editor() {
|
|||||||
_enable_code_editor();
|
_enable_code_editor();
|
||||||
|
|
||||||
_validate_script();
|
_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() {
|
void ScriptTextEditor::_load_theme_settings() {
|
||||||
|
@ -206,7 +206,7 @@ public:
|
|||||||
virtual void apply_code() override;
|
virtual void apply_code() override;
|
||||||
virtual Ref<Resource> get_edited_resource() const override;
|
virtual Ref<Resource> get_edited_resource() const override;
|
||||||
virtual void set_edited_resource(const Ref<Resource> &p_res) 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 Vector<String> get_functions() override;
|
||||||
virtual void reload_text() override;
|
virtual void reload_text() override;
|
||||||
virtual String get_name() override;
|
virtual String get_name() override;
|
||||||
|
@ -108,7 +108,7 @@ void TextEditor::set_edited_resource(const Ref<Resource> &p_res) {
|
|||||||
code_editor->update_line_and_column();
|
code_editor->update_line_and_column();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditor::enable_editor() {
|
void TextEditor::enable_editor(Control *p_shortcut_context) {
|
||||||
if (editor_enabled) {
|
if (editor_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -116,6 +116,15 @@ void TextEditor::enable_editor() {
|
|||||||
editor_enabled = true;
|
editor_enabled = true;
|
||||||
|
|
||||||
_load_theme_settings();
|
_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) {
|
void TextEditor::add_callback(const String &p_function, PackedStringArray p_args) {
|
||||||
|
@ -111,7 +111,7 @@ public:
|
|||||||
virtual Ref<Texture2D> get_theme_icon() override;
|
virtual Ref<Texture2D> get_theme_icon() override;
|
||||||
virtual Ref<Resource> get_edited_resource() const override;
|
virtual Ref<Resource> get_edited_resource() const override;
|
||||||
virtual void set_edited_resource(const Ref<Resource> &p_res) 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 reload_text() override;
|
||||||
virtual void apply_code() override;
|
virtual void apply_code() override;
|
||||||
virtual bool is_unsaved() override;
|
virtual bool is_unsaved() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user