Repository: godotengine/godot
File: editor/plugins/canvas_item_editor_plugin.cpp (C++)

Code before:
		return;
	}

	CheckBox *check = Object::cast_to<CheckBox>(button_group->get_pressed_button());
	default_texture_node_type = check->get_text();
	_perform_drop_data();
	selector->hide();
}

void CanvasItemEditorViewport::_on_change_type_closed() {
	_remove_preview();
}

void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const {
	bool add_preview = false;
	for (int i = 0; i < files.size(); i++) {
		Ref<Resource> res = ResourceLoader::load(files[i]);
		ERR_FAIL_COND(res.is_null());
		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.");
			}
			if (texture != nullptr) {
				Sprite2D *sprite = memnew(Sprite2D);
				sprite->set_texture(texture);
				sprite->set_modulate(Color(1, 1, 1, 0.7f));
				preview_node->add_child(sprite);
				label->show();
				label_desc->show();
				desc += "\n" + TTR("Hold Alt + Shift when dropping to add as a different node type.");
				label_desc->set_text(desc);
			} else {
				if (scene.is_valid()) {
					Node *instance = scene->instantiate();
					if (instance) {
						preview_node->add_child(instance);
						label_desc->show();
						label_desc->set_text(desc);
					}
				}
			}
			add_preview = true;
		}
	}

	if (add_preview) {
		EditorNode::get_singleton()->get_scene_root()->add_child(preview_node);

Review comment (bug):
```suggestion
					"\n" + TTR("Hold Alt when dropping to add as child of root node.");

			if (texture != nullptr) {
```

Code after:
		return;
	}

	CheckBox *check = Object::cast_to<CheckBox>(button_group->get_pressed_button());
	default_texture_node_type = check->get_text();
	_perform_drop_data();
	selector->hide();
}

void CanvasItemEditorViewport::_on_change_type_closed() {
	_remove_preview();
}

void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const {
	bool add_preview = false;
	for (int i = 0; i < files.size(); i++) {
		Ref<Resource> res = ResourceLoader::load(files[i]);
		ERR_FAIL_COND(res.is_null());
		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) {
			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);
				sprite->set_modulate(Color(1, 1, 1, 0.7f));
				preview_node->add_child(sprite);
				label->show();
				label_desc->show();
				desc += "\n" + TTR("Hold Alt + Shift when dropping to add as a different node type.");
				label_desc->set_text(desc);
			} else {
				if (scene.is_valid()) {
					Node *instance = scene->instantiate();
					if (instance) {
						preview_node->add_child(instance);
						label_desc->show();
						label_desc->set_text(desc);
					}
				}
			}
			add_preview = true;
		}
	}

	if (add_preview) {
		EditorNode::get_singleton()->get_scene_root()->add_child(preview_node);
	}