Skip to content

Commit

Permalink
Clicking on a node in the scene tree does not switch to canvas/spatia…
Browse files Browse the repository at this point in the history
…l editor if the script editor is currently active
  • Loading branch information
EricEzaM committed Aug 26, 2020
1 parent a609b30 commit 3653a7d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 17 deletions.
7 changes: 3 additions & 4 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,10 +1991,9 @@ void EditorNode::_edit_current() {
if (!changing_scene) {
main_plugin->edit(current_obj);
}
}

else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) {
// update screen main_plugin
} else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || (ScriptEditor::get_singleton()->can_take_away_focus() || Input::get_singleton()->is_key_pressed(KEY_ALT)))) {
// Update screen main_plugin if plugin is different and script editor either doesnt exist, isn't visible or can lose focus.
// Even if script editor can't lose focus, user can override behaviour by pressing alt.

if (!changing_scene) {
if (editor_plugin_screen) {
Expand Down
9 changes: 0 additions & 9 deletions editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,15 +1534,6 @@ void ScriptEditor::_notification(int p_what) {
}
}

bool ScriptEditor::can_take_away_focus() const {
ScriptEditorBase *current = _get_current_editor();
if (current) {
return current->can_lose_focus_on_node_selection();
} else {
return true;
}
}

void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
Expand Down
3 changes: 1 addition & 2 deletions editor/plugins/script_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ class ScriptEditorBase : public VBoxContainer {
virtual void add_callback(const String &p_function, PackedStringArray p_args) = 0;
virtual void update_settings() = 0;
virtual void set_debugger_active(bool p_active) = 0;
virtual bool can_lose_focus_on_node_selection() { return true; }

virtual bool show_members_overview() = 0;

Expand Down Expand Up @@ -483,7 +482,7 @@ class ScriptEditor : public PanelContainer {

void goto_help(const String &p_desc) { _help_class_goto(p_desc); }

bool can_take_away_focus() const;
bool can_take_away_focus() const { return false; };

VSplitContainer *get_left_list_split() { return list_split; }

Expand Down
1 change: 0 additions & 1 deletion editor/plugins/text_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ class TextEditor : public ScriptEditorBase {
virtual void tag_saved_version() override;
virtual void update_settings() override;
virtual bool show_members_overview() override;
virtual bool can_lose_focus_on_node_selection() override { return true; }
virtual void set_debugger_active(bool p_active) override;
virtual void set_tooltip_request_func(String p_method, Object *p_obj) override;
virtual void add_callback(const String &p_function, PackedStringArray p_args) override;
Expand Down
1 change: 0 additions & 1 deletion modules/visual_script/visual_script_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ class VisualScriptEditor : public ScriptEditorBase {
virtual void set_tooltip_request_func(String p_method, Object *p_obj) override;
virtual Control *get_edit_menu() override;
virtual void clear_edit_menu() override;
virtual bool can_lose_focus_on_node_selection() override { return false; }
virtual void validate() override;

static void register_editor();
Expand Down

0 comments on commit 3653a7d

Please sign in to comment.