summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2022-05-18 19:19:38 +0200
committerkobewi <kobewi4e@gmail.com>2022-05-18 23:25:32 +0200
commit95bbffff48ef54654ab3ec308cd5037a1b1aff7f (patch)
tree245a99ccb6f6b4a67e56bcd9a67ceb24428df836 /editor
parent838cb598e3ef5572018d3d549c15bb27b0a5864d (diff)
Only switch to node when not dragging it
Diffstat (limited to 'editor')
-rw-r--r--editor/scene_tree_dock.cpp29
-rw-r--r--editor/scene_tree_dock.h3
2 files changed, 16 insertions, 16 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index afb3ac7c15..99a1cffa30 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -59,10 +59,7 @@
#endif // MODULE_REGEX_ENABLED
void SceneTreeDock::_nodes_drag_begin() {
- if (restore_script_editor_on_drag) {
- EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
- restore_script_editor_on_drag = false;
- }
+ pending_click_select = nullptr;
}
void SceneTreeDock::_quick_open() {
@@ -74,8 +71,9 @@ void SceneTreeDock::input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
- if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
- restore_script_editor_on_drag = false; //lost chance
+ 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;
}
}
@@ -1369,8 +1367,14 @@ void SceneTreeDock::_script_open_request(const Ref<Script> &p_script) {
}
void SceneTreeDock::_push_item(Object *p_object) {
- if (!Input::get_singleton()->is_key_pressed(Key::ALT)) {
- EditorNode::get_singleton()->push_item(p_object);
+ EditorNode::get_singleton()->push_item(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) {
+ pending_click_select = p_node;
+ } else {
+ EditorNode::get_singleton()->push_item(p_node);
}
}
@@ -1380,12 +1384,7 @@ void SceneTreeDock::_node_selected() {
if (!node) {
return;
}
-
- if (ScriptEditor::get_singleton()->is_visible_in_tree()) {
- restore_script_editor_on_drag = true;
- }
-
- _push_item(node);
+ _handle_select(node);
}
void SceneTreeDock::_node_renamed() {
@@ -2148,7 +2147,7 @@ void SceneTreeDock::_selection_changed() {
//automatically turn on multi-edit
_tool_selected(TOOL_MULTI_EDIT);
} else if (selection_size == 1) {
- _push_item(editor_selection->get_selection().begin()->key);
+ _handle_select(editor_selection->get_selection().begin()->key);
} else if (selection_size == 0) {
_push_item(nullptr);
}
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index 1e58a7a66a..eff34b518c 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -105,7 +105,6 @@ class SceneTreeDock : public VBoxContainer {
Vector<ObjectID> subresources;
- bool restore_script_editor_on_drag = false;
bool reset_create_dialog = false;
int current_option = 0;
@@ -172,6 +171,7 @@ class SceneTreeDock : public VBoxContainer {
void _do_create(Node *p_parent);
Node *scene_root = nullptr;
Node *edited_scene = nullptr;
+ Node *pending_click_select = nullptr;
VBoxContainer *create_root_dialog = nullptr;
String selected_favorite_root;
@@ -198,6 +198,7 @@ class SceneTreeDock : public VBoxContainer {
void _load_request(const String &p_path);
void _script_open_request(const Ref<Script> &p_script);
void _push_item(Object *p_object);
+ void _handle_select(Node *p_node);
bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
bool _track_inherit(const String &p_target_scene_path, Node *p_desired_node);