소스 검색

Merge pull request #41520 from Tony-Goat/patch-1

Added string length checking to LineEdit.set_text()
Rémi Verschelde 5 년 전
부모
커밋
a70038293c
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      scene/gui/line_edit.cpp

+ 6 - 1
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();