1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Fix multi-selection doesn't correctly show in the inspector

(cherry picked from commit 16decbc0ee)
This commit is contained in:
ray90514
2021-04-13 18:09:53 +08:00
committed by Rémi Verschelde
parent e2934a04e2
commit bf645099a1

View File

@@ -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 CanvasItemEditor::_select_click_on_item(CanvasItem *item, Point2 p_click_pos, bool p_append) {
bool still_selected = true; bool still_selected = true;
if (p_append) { if (p_append && !editor_selection->get_selected_node_list().empty()) {
if (editor_selection->is_selected(item)) { if (editor_selection->is_selected(item)) {
// Already in the selection, remove it from the selected nodes // Already in the selection, remove it from the selected nodes
editor_selection->remove_node(item); editor_selection->remove_node(item);
still_selected = false; still_selected = false;
if (editor_selection->get_selected_node_list().size() == 1) {
editor->push_item(editor_selection->get_selected_node_list()[0]);
}
} else { } else {
// Add the item to the selection // Add the item to the selection
editor_selection->add_node(item); editor_selection->add_node(item);
@@ -2440,6 +2444,9 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
SWAP(bsfrom.y, bsto.y); SWAP(bsfrom.y, bsto.y);
_find_canvas_items_in_rect(Rect2(bsfrom, bsto - bsfrom), scene, &selitems); _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<CanvasItem *>::Element *E = selitems.front(); E; E = E->next()) { for (List<CanvasItem *>::Element *E = selitems.front(); E; E = E->next()) {
editor_selection->add_node(E->get()); editor_selection->add_node(E->get());
} }