From bf645099a19000d507fd1c0b76935a24115c7c25 Mon Sep 17 00:00:00 2001 From: ray90514 Date: Tue, 13 Apr 2021 18:09:53 +0800 Subject: [PATCH] Fix multi-selection doesn't correctly show in the inspector (cherry picked from commit 16decbc0ee82c40405e9764eada04e9ac310e36e) --- editor/plugins/canvas_item_editor_plugin.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index ca7c30be1bd..0b7178ab087 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -783,11 +783,15 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n bool CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_pos, bool p_append) { bool still_selected = true; - if (p_append) { + if (p_append && !editor_selection->get_selected_node_list().empty()) { if (editor_selection->is_selected(item)) { // Already in the selection, remove it from the selected nodes editor_selection->remove_node(item); still_selected = false; + + if (editor_selection->get_selected_node_list().size() == 1) { + editor->push_item(editor_selection->get_selected_node_list()[0]); + } } else { // Add the item to the selection editor_selection->add_node(item); @@ -2440,6 +2444,9 @@ bool CanvasItemEditor::_gui_input_select(const Ref &p_event) { SWAP(bsfrom.y, bsto.y); _find_canvas_items_in_rect(Rect2(bsfrom, bsto - bsfrom), scene, &selitems); + if (selitems.size() == 1 && editor_selection->get_selected_node_list().empty()) { + editor->push_item(selitems[0]); + } for (List::Element *E = selitems.front(); E; E = E->next()) { editor_selection->add_node(E->get()); }