summaryrefslogtreecommitdiff
path: root/editor/scene_tree_dock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/scene_tree_dock.cpp')
-rw-r--r--editor/scene_tree_dock.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index d8d44a635a..8506c75a68 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -67,6 +67,9 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
if (get_viewport()->get_modal_stack_top())
return; //ignore because of modal window
+ if (get_focus_owner() && get_focus_owner()->is_text_field())
+ return;
+
if (!p_event->is_pressed() || p_event->is_echo())
return;
@@ -237,13 +240,20 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
Node *parent = base->get_parent();
int pos = base->get_index();
- memdelete(base);
+ parent->remove_child(base);
parent->add_child(instanced_scene);
parent->move_child(instanced_scene, pos);
instanced_scene->set_owner(edited_scene);
editor_selection->clear();
editor_selection->add_node(instanced_scene);
scene_tree->set_selected(instanced_scene);
+
+ // Delete the node as late as possible because before another one is selected
+ // an editor plugin could be referencing it to do something with it before
+ // switching to another (or to none); and since some steps of changing the
+ // editor state are deferred, the safest thing is to do this is as the last
+ // step of this function and also by enqueing instead of memdelete()-ing it here
+ base->queue_delete();
}
bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
@@ -343,8 +353,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (existing.is_valid()) {
const RefPtr empty;
selected->set_script(empty);
- button_create_script->show();
- button_clear_script->hide();
+ _update_script_button();
}
} break;
@@ -1204,8 +1213,7 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) {
return;
selected->set_script(p_script.get_ref_ptr());
editor->push_item(p_script.operator->());
- button_create_script->hide();
- button_clear_script->show();
+ _update_script_button();
}
void SceneTreeDock::_delete_confirm() {
@@ -1292,15 +1300,8 @@ void SceneTreeDock::_delete_confirm() {
EditorNode::get_singleton()->call("_prepare_history");
}
-void SceneTreeDock::_selection_changed() {
-
- int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size();
- if (selection_size > 1) {
- //automatically turn on multi-edit
- _tool_selected(TOOL_MULTI_EDIT);
- }
-
- if (selection_size == 1) {
+void SceneTreeDock::_update_script_button() {
+ if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) {
if (EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
button_create_script->show();
button_clear_script->hide();
@@ -1314,6 +1315,16 @@ void SceneTreeDock::_selection_changed() {
}
}
+void SceneTreeDock::_selection_changed() {
+
+ int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size();
+ if (selection_size > 1) {
+ //automatically turn on multi-edit
+ _tool_selected(TOOL_MULTI_EDIT);
+ }
+ _update_script_button();
+}
+
void SceneTreeDock::_create() {
if (current_option == TOOL_NEW) {
@@ -1648,6 +1659,7 @@ void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) {
Node *n = get_node(p_to);
if (n) {
n->set_script(scr.get_ref_ptr());
+ _update_script_button();
}
}
@@ -2057,6 +2069,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
menu->connect("id_pressed", this, "_tool_selected");
menu_subresources = memnew(PopupMenu);
menu_subresources->set_name("Sub-Resources");
+ menu_subresources->connect("id_pressed", this, "_tool_selected");
menu->add_child(menu_subresources);
first_enter = true;
restore_script_editor_on_drag = false;