From f28230b06ac7540ba945ab7e8db9709ff14f2aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 3 Apr 2017 15:26:57 +0200 Subject: [PATCH] [escher] When textfield receive "^2" (square) event, the cursor should position after the 2 Change-Id: I76c0cf4724f06e7af70a329701003bc32d61fde8 --- 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 7a940fda6..f121dcacc 100644 --- a/escher/src/text_field.cpp +++ b/escher/src/text_field.cpp @@ -333,7 +333,9 @@ bool TextField::handleEvent(Ion::Events::Event event) { setEditing(true); insertTextAtLocation(event.text(), cursorLocation()); } - int cursorDelta = strlen(event.text()) > 1 ? -1 : 0; + /* All events whose text is longer than 2 have parenthesis. In these cases, + * we want to position the cursor before the last parenthesis */ + int cursorDelta = strlen(event.text()) > 2 ? -1 : 0; setCursorLocation(cursorLocation() + strlen(event.text()) + cursorDelta); layoutSubviews(); return true;