summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/create_dialog.cpp49
-rw-r--r--editor/project_manager.cpp4
2 files changed, 32 insertions, 21 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 4bd7371c21..73468f8ce0 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -513,30 +513,45 @@ String CreateDialog::get_selected_type() {
Object *CreateDialog::instance_selected() {
TreeItem *selected = search_options->get_selected();
- if (selected) {
- Variant md = selected->get_metadata(0);
+ if (!selected) {
+ return nullptr;
+ }
- String custom;
- if (md.get_type() != Variant::NIL) {
- custom = md;
- }
+ Variant md = selected->get_metadata(0);
+ String custom;
+ if (md.get_type() != Variant::NIL) {
+ custom = md;
+ }
- if (custom != String()) {
- if (ScriptServer::is_global_class(custom)) {
- Object *obj = EditorNode::get_editor_data().script_class_instance(custom);
- Node *n = Object::cast_to<Node>(obj);
- if (n) {
- n->set_name(custom);
- }
- return obj;
+ Object *obj = nullptr;
+
+ if (!custom.empty()) {
+ if (ScriptServer::is_global_class(custom)) {
+ obj = EditorNode::get_editor_data().script_class_instance(custom);
+ Node *n = Object::cast_to<Node>(obj);
+ if (n) {
+ n->set_name(custom);
}
- return EditorNode::get_editor_data().instance_custom_type(selected->get_text(0), custom);
+ obj = n;
} else {
- return ClassDB::instance(selected->get_text(0));
+ obj = EditorNode::get_editor_data().instance_custom_type(selected->get_text(0), custom);
+ }
+ } else {
+ obj = ClassDB::instance(selected->get_text(0));
+ }
+
+ // Check if any Object-type property should be instantiated.
+ List<PropertyInfo> pinfo;
+ obj->get_property_list(&pinfo);
+
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+ if (E->get().type == Variant::OBJECT && E->get().usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) {
+ Object *prop = ClassDB::instance(E->get().class_name);
+ obj->set(E->get().name, prop);
}
}
- return nullptr;
+ return obj;
}
void CreateDialog::_item_selected() {
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 499f7d4017..cbba4b4834 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1741,10 +1741,6 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
select_project(clicked_index);
}
- if (_selected_project_keys.has(clicked_project.project_key)) {
- clicked_project.control->grab_focus();
- }
-
emit_signal(SIGNAL_SELECTION_CHANGED);
if (!mb->get_control() && mb->is_doubleclick()) {