From dede3610f3fe32f2858dcd5d865798a8c9d77558 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 3 Oct 2017 14:45:53 -0300 Subject: [PATCH] Fix bug inserting the first char in a text entry If a text field (ui::Entry) contains text with length=1 (e.g. the number "8"), and we focus and press that same char ("8"), the caret will be in the position 0 with text "8" (the caret should be in position 1). this patch fix this behavior. --- src/ui/entry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/entry.cpp b/src/ui/entry.cpp index 0b6962a93..1e3999e90 100644 --- a/src/ui/entry.cpp +++ b/src/ui/entry.cpp @@ -559,6 +559,7 @@ void Entry::executeCmd(EntryCmd cmd, int unicodeChar, bool shift_pressed) text.insert(m_boxes[m_caret].from, base::to_utf8(unicodeStr)); + recalcCharBoxes(text); ++m_caret; } @@ -626,7 +627,7 @@ void Entry::executeCmd(EntryCmd cmd, int unicodeChar, bool shift_pressed) else m_select = -1; - m_caret = text.size(); + m_caret = lastCaretPos(); break; case EntryCmd::DeleteForward: