summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-04-21 13:25:38 +0200
committerGitHub <noreply@github.com>2019-04-21 13:25:38 +0200
commit2226ce0fa8fae5b3fdd532d3bf486a1519905710 (patch)
tree14a6ac277b3a8a8b98bdd3cff772e1a2abd7ff49 /scene/gui
parentabaee11f4f988c03549d5fc2942dba1311bb987c (diff)
parentd84acb98d0863ec142a9496bd229e7163deaefe8 (diff)
Merge pull request #28248 from YeldhamDev/lineedit_clearbutton_limit
Fix 'LineEdit' contents not ending before the clear button if no right icon was set
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/line_edit.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 0c5dc39273..e83ef95db6 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1159,8 +1159,10 @@ void LineEdit::set_cursor_position(int p_pos) {
} else if (cursor_pos > window_pos) {
/* Adjust window if cursor goes too much to the right */
int window_width = get_size().width - style->get_minimum_size().width;
- if (right_icon.is_valid()) {
- window_width -= right_icon->get_width();
+ bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled;
+ if (right_icon.is_valid() || display_clear_icon) {
+ Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon;
+ window_width -= r_icon->get_width();
}
if (window_width < 0)