[escher] When textfield receive "^2" (square) event, the cursor should

position after the 2

Change-Id: I76c0cf4724f06e7af70a329701003bc32d61fde8
This commit is contained in:
Émilie Feral
2017-04-03 15:26:57 +02:00
parent 5fb32f682c
commit f28230b06a

View File

@@ -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;