Skip to content

Commit

Permalink
Merge pull request #61900 from KoBeWi/clicking_inside_the_box
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Jun 10, 2022
2 parents 9b014c4 + ec6bbd4 commit b9375ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down
1 change: 1 addition & 0 deletions editor/scene_tree_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b9375ea

Please sign in to comment.