summaryrefslogtreecommitdiff
path: root/editor/scene_tree_editor.cpp
diff options
context:
space:
mode:
authorSilc 'Tokage' Renew <61938263+TokageItLab@users.noreply.github.com>2021-07-23 17:34:21 +0900
committerSilc 'Tokage' Renew <61938263+TokageItLab@users.noreply.github.com>2021-07-23 17:34:21 +0900
commit32640edac718a0eaf130719f96450ebf758fc085 (patch)
treeea34514980253471191d520522d2a148c7ad0363 /editor/scene_tree_editor.cpp
parent515670351a5b8d13eef475df9d602e846f53884d (diff)
Revert "Fix duplicate selection in SceneTree"
This reverts commit 7d20d78847b24586b3f25beb23b41d015a25fb0a. # Conflicts: # editor/scene_tree_editor.cpp
Diffstat (limited to 'editor/scene_tree_editor.cpp')
-rw-r--r--editor/scene_tree_editor.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index c6f2c9253e..24fc45dfd3 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -521,7 +521,7 @@ void SceneTreeEditor::_node_removed(Node *p_node) {
if (p_node == selected) {
selected = nullptr;
- _emit_node_selected();
+ emit_signal("node_selected");
}
}
@@ -615,6 +615,24 @@ void SceneTreeEditor::_tree_changed() {
pending_test_update = true;
}
+void SceneTreeEditor::_selected_changed() {
+ TreeItem *s = tree->get_selected();
+ ERR_FAIL_COND(!s);
+ NodePath np = s->get_metadata(0);
+
+ Node *n = get_node(np);
+
+ if (n == selected) {
+ return;
+ }
+
+ selected = get_node(np);
+
+ blocked++;
+ emit_signal("node_selected");
+ blocked--;
+}
+
void SceneTreeEditor::_deselect_items() {
// Clear currently selected items in scene tree dock.
if (editor_selection) {
@@ -623,12 +641,6 @@ void SceneTreeEditor::_deselect_items() {
}
}
-void SceneTreeEditor::_emit_node_selected() {
- blocked++;
- emit_signal(SNAME("node_selected"));
- blocked--;
-}
-
void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_selected) {
TreeItem *item = Object::cast_to<TreeItem>(p_object);
ERR_FAIL_COND(!item);
@@ -655,7 +667,7 @@ void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_
// Selection changed to be single node, so emit "selected" (for single node) rather than "changed" (for multiple nodes)
if (editor_selection->get_selected_nodes().size() == 1) {
selected = editor_selection->get_selected_node_list()[0];
- _emit_node_selected();
+ emit_signal("node_selected");
} else {
emit_signal(SNAME("node_changed"));
}
@@ -747,7 +759,7 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) {
}
if (p_emit_selected) {
- _emit_node_selected();
+ emit_signal("node_selected");
}
}
@@ -1197,6 +1209,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope
tree->connect("empty_tree_rmb_selected", callable_mp(this, &SceneTreeEditor::_rmb_select));
}
+ tree->connect("cell_selected", callable_mp(this, &SceneTreeEditor::_selected_changed));
tree->connect("item_edited", callable_mp(this, &SceneTreeEditor::_renamed), varray(), CONNECT_DEFERRED);
tree->connect("multi_selected", callable_mp(this, &SceneTreeEditor::_cell_multi_selected));
tree->connect("button_pressed", callable_mp(this, &SceneTreeEditor::_cell_button_pressed));