diff options
author | kobewi <kobewi4e@gmail.com> | 2022-06-10 15:14:31 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2022-06-10 15:14:31 +0200 |
commit | ec6bbd486f31245af3764c466431ffc2d13d52ed (patch) | |
tree | 3c8240d71d5434712e7a52f8fa56b75fd2818d7b | |
parent | 9b014c49ba4c66a4cd376633f51d3707680c2503 (diff) |
Don't handle pending clicks outside scene tree
-rw-r--r-- | editor/scene_tree_dock.cpp | 18 | ||||
-rw-r--r-- | editor/scene_tree_dock.h | 1 |
2 files changed, 14 insertions, 5 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 1ddefeba77..9646462ead 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -71,9 +71,17 @@ void SceneTreeDock::input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; - if (pending_click_select && mb.is_valid() && !mb->is_pressed() && (mb->get_button_index() == MouseButton::LEFT || mb->get_button_index() == MouseButton::RIGHT)) { - _push_item(pending_click_select); - pending_click_select = nullptr; + if (mb.is_valid() && (mb->get_button_index() == MouseButton::LEFT || mb->get_button_index() == MouseButton::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; + } } } @@ -1371,10 +1379,10 @@ void SceneTreeDock::_push_item(Object *p_object) { } void SceneTreeDock::_handle_select(Node *p_node) { - if ((Input::get_singleton()->get_mouse_button_mask() & (MouseButton::MASK_LEFT | MouseButton::MASK_RIGHT)) != MouseButton::NONE) { + if (tree_clicked) { pending_click_select = p_node; } else { - EditorNode::get_singleton()->push_item(p_node); + _push_item(p_node); } } diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 54e6108d84..dc7f3476ee 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -172,6 +172,7 @@ class SceneTreeDock : public VBoxContainer { Node *scene_root = nullptr; Node *edited_scene = nullptr; Node *pending_click_select = nullptr; + bool tree_clicked = false; VBoxContainer *create_root_dialog = nullptr; String selected_favorite_root; |