summaryrefslogtreecommitdiff
path: root/editor/plugins/theme_editor_plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/theme_editor_plugin.cpp')
-rw-r--r--editor/plugins/theme_editor_plugin.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 4a4816e3b8..9338ea6ddd 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -1459,13 +1459,16 @@ void ThemeItemEditorDialog::_item_tree_button_pressed(Object *p_item, int p_colu
_update_edit_item_tree(edited_item_type);
}
-void ThemeItemEditorDialog::_add_theme_type() {
- edited_theme->add_icon_type(edit_add_type_value->get_text());
- edited_theme->add_stylebox_type(edit_add_type_value->get_text());
- edited_theme->add_font_type(edit_add_type_value->get_text());
- edited_theme->add_font_size_type(edit_add_type_value->get_text());
- edited_theme->add_color_type(edit_add_type_value->get_text());
- edited_theme->add_constant_type(edit_add_type_value->get_text());
+void ThemeItemEditorDialog::_add_theme_type(const String &p_new_text) {
+ const String new_type = edit_add_type_value->get_text().strip_edges();
+ edit_add_type_value->clear();
+
+ edited_theme->add_icon_type(new_type);
+ edited_theme->add_stylebox_type(new_type);
+ edited_theme->add_font_type(new_type);
+ edited_theme->add_font_size_type(new_type);
+ edited_theme->add_color_type(new_type);
+ edited_theme->add_constant_type(new_type);
_update_edit_types();
// Force emit a change so that other parts of the editor can update.
@@ -1776,11 +1779,12 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() {
edit_dialog_side_vb->add_child(edit_add_type_hb);
edit_add_type_value = memnew(LineEdit);
edit_add_type_value->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ edit_add_type_value->connect("text_submitted", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type));
edit_add_type_hb->add_child(edit_add_type_value);
Button *edit_add_type_button = memnew(Button);
edit_add_type_button->set_text(TTR("Add"));
edit_add_type_hb->add_child(edit_add_type_button);
- edit_add_type_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type));
+ edit_add_type_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type), varray(""));
VBoxContainer *edit_items_vb = memnew(VBoxContainer);
edit_items_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);