summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2020-01-15 09:42:06 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2020-01-15 10:15:32 +0800
commit26e3b4a58a2e47f626166132108c34843b06f85c (patch)
tree3dcbd992ff8947066499976681aa8339a86b03bd /scene
parent40f0649e5b02037cb4745c336170e1e5422467ed (diff)
Updates LineEdit's min size when necessary
These properties will affect the minimum size of LineEdit: * The right icon (`set_right_icon`) * The clear button (`set_editable` and `set_clear_button_enabled`) * The text, when "expand to text length" is enabled (`set_text`)
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/line_edit.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index a6cd9a0665..0f3328dac5 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1239,6 +1239,11 @@ void LineEdit::set_text(String p_text) {
clear_internal();
append_at_cursor(p_text);
+
+ if (expand_to_text_length) {
+ minimum_size_changed();
+ }
+
update();
cursor_pos = 0;
window_pos = 0;
@@ -1482,6 +1487,7 @@ void LineEdit::set_editable(bool p_editable) {
editable = p_editable;
_generate_context_menu();
+ minimum_size_changed();
update();
}
@@ -1617,7 +1623,11 @@ bool LineEdit::get_expand_to_text_length() const {
}
void LineEdit::set_clear_button_enabled(bool p_enabled) {
+ if (clear_button_enabled == p_enabled) {
+ return;
+ }
clear_button_enabled = p_enabled;
+ minimum_size_changed();
update();
}
@@ -1653,6 +1663,7 @@ void LineEdit::set_right_icon(const Ref<Texture> &p_icon) {
return;
}
right_icon = p_icon;
+ minimum_size_changed();
update();
}