From cebfc02d6f1deee4e0a8eafd444e9657a2a86807 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Fri, 24 Feb 2023 21:17:05 +0200 Subject: Revert "Reordering emitted signals in PopupMenu" and fix editor selection issue in the safer way. --- editor/plugins/canvas_item_editor_plugin.cpp | 6 ++++-- editor/plugins/canvas_item_editor_plugin.h | 1 + editor/plugins/node_3d_editor_plugin.cpp | 7 +++++-- editor/plugins/node_3d_editor_plugin.h | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) (limited to 'editor/plugins') diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 0f9ce89f02..75a444c877 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -896,15 +896,16 @@ void CanvasItemEditor::_snap_changed() { } void CanvasItemEditor::_selection_result_pressed(int p_result) { - if (selection_results.size() <= p_result) { + if (selection_results_menu.size() <= p_result) { return; } - CanvasItem *item = selection_results[p_result].item; + CanvasItem *item = selection_results_menu[p_result].item; if (item) { _select_click_on_item(item, Point2(), selection_menu_additive_selection); } + selection_results_menu.clear(); } void CanvasItemEditor::_selection_menu_hide() { @@ -2247,6 +2248,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref &p_event) { selection_menu->set_item_tooltip(i, String(item->get_name()) + "\nType: " + item->get_class() + "\nPath: " + node_path); } + selection_results_menu = selection_results; selection_menu_additive_selection = b->is_shift_pressed(); selection_menu->set_position(viewport->get_screen_transform().xform(b->get_position())); selection_menu->reset_size(); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index ebe87a56f7..c5b9bf9e0b 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -256,6 +256,7 @@ private: } }; Vector<_SelectResult> selection_results; + Vector<_SelectResult> selection_results_menu; struct _HoverResult { Point2 position; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 96f5aeedf0..6580340af4 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -1543,6 +1543,7 @@ void Node3DEditorViewport::_list_select(Ref b) { selection_menu->set_item_tooltip(i, String(spat->get_name()) + "\nType: " + spat->get_class() + "\nPath: " + node_path); } + selection_results_menu = selection_results; selection_menu->set_position(get_screen_position() + b->get_position()); selection_menu->reset_size(); selection_menu->popup(); @@ -3609,15 +3610,17 @@ void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) { } void Node3DEditorViewport::_selection_result_pressed(int p_result) { - if (selection_results.size() <= p_result) { + if (selection_results_menu.size() <= p_result) { return; } - clicked = selection_results[p_result].item->get_instance_id(); + clicked = selection_results_menu[p_result].item->get_instance_id(); if (clicked.is_valid()) { _select_clicked(spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); } + + selection_results_menu.clear(); } void Node3DEditorViewport::_selection_menu_hide() { diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index a1fd9757d0..e5267e5fad 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -290,6 +290,7 @@ private: ObjectID clicked; ObjectID material_target; Vector<_RayResult> selection_results; + Vector<_RayResult> selection_results_menu; bool clicked_wants_append = false; bool selection_in_progress = false; -- cgit v1.2.3