summaryrefslogtreecommitdiffstats
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.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 9ea0a03e68..6c153f6113 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -2287,8 +2287,11 @@ VBoxContainer *ThemeTypeEditor::_create_item_list(Theme::DataType p_data_type) {
item_add_edit->connect("text_submitted", callable_mp(this, &ThemeTypeEditor::_item_add_lineedit_cbk).bind(p_data_type, item_add_edit));
Button *item_add_button = memnew(Button);
item_add_button->set_text(TTR("Add"));
+ item_add_button->set_disabled(true);
item_add_hb->add_child(item_add_button);
item_add_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_add_cbk).bind(p_data_type, item_add_edit));
+ item_add_edit->set_meta("button", item_add_button);
+ item_add_edit->connect("text_changed", callable_mp(this, &ThemeTypeEditor::_update_add_button).bind(item_add_edit));
return items_list;
}
@@ -2850,6 +2853,11 @@ void ThemeTypeEditor::_add_default_type_items() {
ur->commit_action();
}
+void ThemeTypeEditor::_update_add_button(const String &p_text, LineEdit *p_for_edit) {
+ Button *button = Object::cast_to<Button>(p_for_edit->get_meta("button"));
+ button->set_disabled(p_text.strip_edges().is_empty());
+}
+
void ThemeTypeEditor::_item_add_cbk(int p_data_type, Control *p_control) {
LineEdit *le = Object::cast_to<LineEdit>(p_control);
if (le->get_text().strip_edges().is_empty()) {
@@ -2895,6 +2903,7 @@ void ThemeTypeEditor::_item_add_cbk(int p_data_type, Control *p_control) {
ur->commit_action();
le->set_text("");
+ _update_add_button("", le);
}
void ThemeTypeEditor::_item_add_lineedit_cbk(String p_value, int p_data_type, Control *p_control) {