From 24a7bbc9ea1161a7417b13ca2fd6f8f1169a5b4a Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 10 Jun 2022 15:14:31 +0200 Subject: [PATCH] Don't handle pending clicks outside scene tree (cherry picked from commit ec6bbd486f31245af3764c466431ffc2d13d52ed) --- editor/scene_tree_dock.cpp | 19 ++++++++++++++----- editor/scene_tree_dock.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 0faba85b5..b79609c61 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -108,9 +108,17 @@ void SceneTreeDock::_quick_open() { void SceneTreeDock::_input(Ref p_event) { Ref mb = p_event; - if (pending_click_select && mb.is_valid() && !mb->is_pressed() && (mb->get_button_index() == BUTTON_LEFT || mb->get_button_index() == BUTTON_RIGHT)) { - _push_item(pending_click_select); - pending_click_select = nullptr; + if (mb.is_valid() && (mb->get_button_index() == BUTTON_LEFT || mb->get_button_index() == BUTTON_RIGHT)) { + if (mb->is_pressed() && scene_tree->get_rect().has_point(mb->get_position())) { + tree_clicked = true; + } else if (!mb->is_pressed()) { + tree_clicked = false; + } + + if (!mb->is_pressed() && pending_click_select) { + _push_item(pending_click_select); + pending_click_select = nullptr; + } } } @@ -1461,10 +1469,10 @@ void SceneTreeDock::_push_item(Object *p_object) { } void SceneTreeDock::_handle_select(Node *p_node) { - if ((Input::get_singleton()->get_mouse_button_mask() & (BUTTON_MASK_LEFT | BUTTON_MASK_RIGHT)) != 0) { + if (tree_clicked) { pending_click_select = p_node; } else { - editor->push_item(p_node); + _push_item(p_node); } } @@ -3294,6 +3302,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel editor_selection = p_editor_selection; scene_root = p_scene_root; pending_click_select = nullptr; + tree_clicked = false; VBoxContainer *vbc = this; diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 53a04fa11..c73490404 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -192,6 +192,7 @@ class SceneTreeDock : public VBoxContainer { Node *edited_scene; Node *pending_click_select; EditorNode *editor; + bool tree_clicked; VBoxContainer *create_root_dialog; String selected_favorite_root;