Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default parenting behavior when drag-and-dropping to 2d and 3d editor #91874

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading