summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-05-17 11:13:57 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-05-17 11:13:57 +0200
commitb201c7fc137efd54b35060fcd3e78f5dbf46b8d6 (patch)
tree6fcf7864d7965e72bda58dbb11d5b870422d369d
parent62353747e538fcf44766871ee158c5b33b8da461 (diff)
parent8e0f0c6edbf8ca7457a4c2d562e1d43f18121b88 (diff)
downloadredot-engine-b201c7fc137efd54b35060fcd3e78f5dbf46b8d6.tar.gz
Merge pull request #91874 from Nodragem/editor-scene-drag-and-drop-default
Change default parenting behavior when drag-and-dropping to 2d and 3d editor
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp16
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp7
2 files changed, 12 insertions, 11 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 731c89250e..a44430ca7f 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -5732,11 +5732,10 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != nullptr || scene != nullptr) {
- bool root_node_selected = EditorNode::get_singleton()->get_editor_selection()->is_selected(EditorNode::get_singleton()->get_edited_scene());
- String desc = TTR("Drag and drop to add as child of selected node.") + "\n" + TTR("Hold Alt when dropping to add as child of root node.");
- if (!root_node_selected) {
- desc += "\n" + TTR("Hold Shift when dropping to add as sibling of selected node.");
- }
+ String desc = TTR("Drag and drop to add as sibling of selected node (except when root is selected).") +
+ "\n" + TTR("Hold Shift when dropping to add as child of selected node.") +
+ "\n" + TTR("Hold Alt when dropping to add as child of root node.");
+
if (texture != nullptr) {
Sprite2D *sprite = memnew(Sprite2D);
sprite->set_texture(texture);
@@ -6099,11 +6098,12 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
Node *root_node = EditorNode::get_singleton()->get_edited_scene();
if (selected_nodes.size() > 0) {
Node *selected_node = selected_nodes.front()->get();
- target_node = selected_node;
if (is_alt) {
target_node = root_node;
- } else if (is_shift && selected_node != root_node) {
- target_node = selected_node->get_parent();
+ } else if (is_shift) {
+ target_node = selected_node;
+ } else { // Default behavior.
+ target_node = (selected_node != root_node) ? selected_node->get_parent() : root_node;
}
} else {
if (root_node) {
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 5873d10e76..ca7ea821e8 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -4593,11 +4593,12 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
Node *root_node = EditorNode::get_singleton()->get_edited_scene();
if (selected_nodes.size() > 0) {
Node *selected_node = selected_nodes.front()->get();
- target_node = selected_node;
if (is_alt) {
target_node = root_node;
- } else if (is_shift && selected_node != root_node) {
- target_node = selected_node->get_parent();
+ } else if (is_shift) {
+ target_node = selected_node;
+ } else { // Default behavior.
+ target_node = (selected_node != root_node) ? selected_node->get_parent() : root_node;
}
} else {
if (root_node) {