Don't handle pending clicks outside scene tree

(cherry picked from commit ec6bbd486f31245af3764c466431ffc2d13d52ed)
This commit is contained in:
kobewi 2022-06-10 15:14:31 +02:00 committed by Relintai
parent 3659429afd
commit 24a7bbc9ea
2 changed files with 15 additions and 5 deletions

View File

@ -108,9 +108,17 @@ void SceneTreeDock::_quick_open() {
void SceneTreeDock::_input(Ref<InputEvent> p_event) {
Ref<InputEventMouseButton> 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;

View File

@ -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;