From 860553b7358de6ef10366daa07e3a996e98ac9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 19 Nov 2018 10:10:34 +0100 Subject: [PATCH] [escher] Fix cursor position in textfield The cursor was not in the right place in TextFieldWithExtension --- escher/src/text_field.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/escher/src/text_field.cpp b/escher/src/text_field.cpp index 098236845..5e9ac4747 100644 --- a/escher/src/text_field.cpp +++ b/escher/src/text_field.cpp @@ -64,7 +64,6 @@ void TextField::ContentView::setText(const char * text) { // Update the draft text length and cursor location if (m_isEditing || m_textBuffer == m_draftTextBuffer) { m_currentDraftTextLength = textLength; - setCursorLocation(textLength); } reloadRectFromCursorPosition(0); } @@ -227,6 +226,9 @@ size_t TextField::draftTextLength() const { void TextField::setText(const char * text) { reloadScroll(); m_contentView.setText(text); + /* Set the cursor location here and not in ContentView::setText so that + * TextInput::willSetCursorLocation is called. */ + setCursorLocation(strlen(text)); } void TextField::setAlignment(float horizontalAlignment, float verticalAlignment) {