From 24b3bf06375ff408fce82e698f264e32913d237c Mon Sep 17 00:00:00 2001 From: Thibault Truffert Date: Sat, 6 Jun 2020 17:39:53 +0200 Subject: [PATCH] Make text deletion methods public for LineEdit (cherry picked from commit 2bb44ea5bd57ddaeb7ede96f13736767e4b30342) --- scene/gui/line_edit.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index f255b643f0b..8211e1f6798 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1207,6 +1207,8 @@ void LineEdit::delete_char() { void LineEdit::delete_text(int p_from_column, int p_to_column) { + ERR_FAIL_COND_MSG(p_from_column < 0 || p_from_column > p_to_column || p_to_column > text.length(), + vformat("Positional parameters (from: %d, to: %d) are inverted or outside the text length (%d).", p_from_column, p_to_column, text.length())); if (text.size() > 0) { Ref font = get_font("font"); if (font != NULL) { @@ -1791,6 +1793,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("set_max_length", "chars"), &LineEdit::set_max_length); ClassDB::bind_method(D_METHOD("get_max_length"), &LineEdit::get_max_length); ClassDB::bind_method(D_METHOD("append_at_cursor", "text"), &LineEdit::append_at_cursor); + ClassDB::bind_method(D_METHOD("delete_char_at_cursor"), &LineEdit::delete_char); + ClassDB::bind_method(D_METHOD("delete_text", "from_column", "to_column"), &LineEdit::delete_text); ClassDB::bind_method(D_METHOD("set_editable", "enabled"), &LineEdit::set_editable); ClassDB::bind_method(D_METHOD("is_editable"), &LineEdit::is_editable); ClassDB::bind_method(D_METHOD("set_secret", "enabled"), &LineEdit::set_secret);