diff options
author | viksl <33526847+viksl@users.noreply.github.com> | 2023-11-02 11:07:29 +0100 |
---|---|---|
committer | viksl <33526847+viksl@users.noreply.github.com> | 2024-02-14 20:03:00 +0100 |
commit | dc60c01e56ce441f85cf7ac4dfcc22a1af5059e5 (patch) | |
tree | 5b3bc56f3ff016d92aa2638b81cf6a06370a970b | |
parent | 907db8eebcecb97d527edcaff77a1c87a6c068f5 (diff) | |
download | redot-engine-dc60c01e56ce441f85cf7ac4dfcc22a1af5059e5.tar.gz |
Select newly added nodes on drag and drop in 2D viewport
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 987a28adc9..9d7305f9ae 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5811,10 +5811,12 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons instantiated_scene->set_scene_file_path(ProjectSettings::get_singleton()->localize_path(path)); EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); + EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); undo_redo->add_do_method(parent, "add_child", instantiated_scene, true); undo_redo->add_do_method(instantiated_scene, "set_owner", edited_scene); undo_redo->add_do_reference(instantiated_scene); undo_redo->add_undo_method(parent, "remove_child", instantiated_scene); + undo_redo->add_do_method(editor_selection, "add_node", instantiated_scene); String new_name = parent->validate_child_name(instantiated_scene); EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton(); @@ -5853,6 +5855,8 @@ void CanvasItemEditorViewport::_perform_drop_data() { EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->create_action_for_history(TTR("Create Node"), EditorNode::get_editor_data().get_current_edited_scene_history_id()); + EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); + undo_redo->add_do_method(editor_selection, "clear"); for (int i = 0; i < selected_files.size(); i++) { String path = selected_files[i]; @@ -5879,6 +5883,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { if (texture != nullptr && texture.is_valid()) { Node *child = Object::cast_to<Node>(ClassDB::instantiate(default_texture_node_type)); _create_nodes(target_node, child, path, drop_pos); + undo_redo->add_do_method(editor_selection, "add_node", child); } } } |