diff options
author | Tony-Goat <70238376+Tony-Goat@users.noreply.github.com> | 2020-08-25 15:58:03 -0600 |
---|---|---|
committer | Kyle Kuhn <kylekuhn99@gmail.com> | 2020-08-26 11:19:24 -0600 |
commit | 71febfd6e2f6187fcc106ce715124cf173bfa0b8 (patch) | |
tree | 7216b460e1d7538de9addbc237d6f4fc025c7edb /scene | |
parent | a609b30ddb77bcc1c64008a7848da07b5448a10d (diff) |
Updated LineEdit to address #41278
Updated set_max_length() function to actually pull a substring of the current text so it's not all thrown away when the new max length is shorter than the current length.
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/line_edit.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 14167531a5..162949fd69 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1281,7 +1281,12 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) { void LineEdit::set_text(String p_text) { clear_internal(); - append_at_cursor(p_text); + + if (p_text.length() > max_length) { + append_at_cursor(p_text.substr(0, max_length)); + } else { + append_at_cursor(p_text); + } if (expand_to_text_length) { minimum_size_changed(); |