@@ -182,11 +182,13 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
182
182
bool can_instance = (cpp_type && ClassDB::can_instance (p_type)) || ScriptServer::is_global_class (p_type);
183
183
184
184
TreeItem *item = search_options->create_item (parent);
185
+ item->set_text (0 , p_type);
185
186
if (cpp_type) {
186
- item->set_text (0 , p_type);
187
+ item->set_tooltip (0 , DTR ( EditorHelp::get_doc_data ()-> class_list [ p_type]. brief_description ) );
187
188
} else {
189
+ item->set_tooltip (0 , ScriptServer::get_global_class_path (p_type));
190
+ item->add_button (0 , EditorNode::get_singleton ()->get_class_icon (" Script" ));
188
191
item->set_metadata (0 , p_type);
189
- item->set_text (0 , p_type + " (" + ScriptServer::get_global_class_path (p_type).get_file () + " )" );
190
192
}
191
193
if (!can_instance) {
192
194
item->set_custom_color (0 , get_color (" disabled_font_color" , " Editor" ));
@@ -244,9 +246,6 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
244
246
item->set_collapsed (collapse);
245
247
}
246
248
247
- const String &description = DTR (EditorHelp::get_doc_data ()->class_list [p_type].brief_description );
248
- item->set_tooltip (0 , description);
249
-
250
249
String icon_fallback = has_icon (base_type, " EditorIcons" ) ? base_type : " Object" ;
251
250
item->set_icon (0 , EditorNode::get_singleton ()->get_class_icon (p_type, icon_fallback));
252
251
@@ -555,25 +554,32 @@ void CreateDialog::_item_selected() {
555
554
favorite->set_disabled (false );
556
555
favorite->set_pressed (favorite_list.find (name) != -1 );
557
556
558
- if (!EditorHelp::get_doc_data ()->class_list .has (name)) {
559
- return ;
560
- }
561
-
562
- const String brief_desc = DTR (EditorHelp::get_doc_data ()->class_list [name].brief_description );
563
- if (!brief_desc.empty ()) {
564
- // Display both class name and description, since the help bit may be displayed
565
- // far away from the location (especially if the dialog was resized to be taller).
566
- help_bit->set_text (vformat (" [b]%s[/b]: %s" , name, brief_desc));
567
- help_bit->get_rich_text ()->set_self_modulate (Color (1 , 1 , 1 , 1 ));
557
+ const String brief_desc = item->get_tooltip (0 );
558
+ if (EditorHelp::get_doc_data ()->class_list .has (name)) {
559
+ help_bit->set_text (vformat (" [%s] %s" , name, brief_desc));
568
560
} else {
569
- // Use nested `vformat()` as translators shouldn't interfere with BBCode tags.
570
- help_bit->set_text (vformat (TTR (" No description available for %s." ), vformat (" [b]%s[/b]" , name)));
571
- help_bit->get_rich_text ()->set_self_modulate (Color (1 , 1 , 1 , 0.5 ));
561
+ help_bit->set_text (vformat (" [url=%s]%s[/url]" , brief_desc, name));
572
562
}
573
563
564
+ help_bit->get_rich_text ()->set_self_modulate (Color (1 , 1 , 1 , 1 ));
565
+
574
566
get_ok ()->set_disabled (false );
575
567
}
576
568
569
+ void CreateDialog::_script_selected (const Variant &p_object, int p_column, int p_id) {
570
+ TreeItem *p_item = Object::cast_to<TreeItem>(p_object);
571
+ String script_path = p_item->get_tooltip (0 );
572
+ if (!script_path.empty ()) {
573
+ Ref<Script> script = ResourceLoader::load (script_path, " Script" );
574
+ if (script.is_valid ()) {
575
+ EditorNode::get_singleton ()->edit_resource (script);
576
+ } else {
577
+ print_error (" Failed to load script: " + script_path);
578
+ }
579
+ hide ();
580
+ }
581
+ }
582
+
577
583
void CreateDialog::_favorite_toggled () {
578
584
TreeItem *item = search_options->get_selected ();
579
585
if (!item) {
@@ -743,6 +749,7 @@ void CreateDialog::_bind_methods() {
743
749
ClassDB::bind_method (D_METHOD (" _confirmed" ), &CreateDialog::_confirmed);
744
750
ClassDB::bind_method (D_METHOD (" _sbox_input" ), &CreateDialog::_sbox_input);
745
751
ClassDB::bind_method (D_METHOD (" _item_selected" ), &CreateDialog::_item_selected);
752
+ ClassDB::bind_method (D_METHOD (" _script_selected" ), &CreateDialog::_script_selected);
746
753
ClassDB::bind_method (D_METHOD (" _favorite_toggled" ), &CreateDialog::_favorite_toggled);
747
754
ClassDB::bind_method (D_METHOD (" _history_selected" ), &CreateDialog::_history_selected);
748
755
ClassDB::bind_method (D_METHOD (" _favorite_selected" ), &CreateDialog::_favorite_selected);
@@ -821,6 +828,7 @@ CreateDialog::CreateDialog() {
821
828
set_hide_on_ok (false );
822
829
search_options->connect (" item_activated" , this , " _confirmed" );
823
830
search_options->connect (" cell_selected" , this , " _item_selected" );
831
+ search_options->connect (" button_pressed" , this , " _script_selected" );
824
832
base_type = " Object" ;
825
833
preferred_search_result_type = " " ;
826
834
0 commit comments