summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/gui/line_edit.cpp7
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();