Merge pull request #94105 from KoBeWi/same_parent_new_problems
Fix wrong inspected node after drag&drop
This commit is contained in:
commit
b0467d07bf
|
@ -2276,6 +2276,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
|
||||||
Vector<StringName> former_names;
|
Vector<StringName> former_names;
|
||||||
|
|
||||||
int inc = 0;
|
int inc = 0;
|
||||||
|
bool need_edit = false;
|
||||||
|
|
||||||
for (int ni = 0; ni < p_nodes.size(); ni++) {
|
for (int ni = 0; ni < p_nodes.size(); ni++) {
|
||||||
// No undo implemented for this yet.
|
// No undo implemented for this yet.
|
||||||
|
@ -2296,7 +2297,11 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
|
||||||
inc--; // If the child will generate a gap when moved, adjust.
|
inc--; // If the child will generate a gap when moved, adjust.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!same_parent) {
|
if (same_parent) {
|
||||||
|
// When node is reparented to the same parent, EditorSelection does not change.
|
||||||
|
// After hovering another node, the inspector has to be manually updated in this case.
|
||||||
|
need_edit = select_node_hovered_at_end_of_drag;
|
||||||
|
} else {
|
||||||
undo_redo->add_do_method(node->get_parent(), "remove_child", node);
|
undo_redo->add_do_method(node->get_parent(), "remove_child", node);
|
||||||
undo_redo->add_do_method(new_parent, "add_child", node, true);
|
undo_redo->add_do_method(new_parent, "add_child", node, true);
|
||||||
}
|
}
|
||||||
|
@ -2401,6 +2406,10 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
|
||||||
perform_node_renames(nullptr, &path_renames);
|
perform_node_renames(nullptr, &path_renames);
|
||||||
|
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
|
|
||||||
|
if (need_edit) {
|
||||||
|
EditorNode::get_singleton()->edit_current();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTreeDock::_script_created(Ref<Script> p_script) {
|
void SceneTreeDock::_script_created(Ref<Script> p_script) {
|
||||||
|
|
Loading…
Reference in New Issue