[apps] Calling draftTextLength should be done only if text field is editing

This commit is contained in:
Léa Saviot
2019-01-25 08:43:49 +01:00
committed by Émilie Feral
parent 94b4cbc8d5
commit 4688e9535f

View File

@@ -350,9 +350,11 @@ bool MenuController::textFieldDidFinishEditing(TextField * textField, const char
bool MenuController::textFieldDidHandleEvent(TextField * textField, bool returnValue, bool textSizeDidChange) {
int scriptExtensionLength = 1 + strlen(ScriptStore::k_scriptExtension);
const char * maxPointerLocation = textField->text() + textField->draftTextLength() - scriptExtensionLength;
if (textField->isEditing() && textField->cursorLocation() > maxPointerLocation) {
textField->setCursorLocation(maxPointerLocation);
if (textField->isEditing()) {
const char * maxPointerLocation = textField->text() + textField->draftTextLength() - scriptExtensionLength;
if (textField->cursorLocation() > maxPointerLocation) {
textField->setCursorLocation(maxPointerLocation);
}
}
return returnValue;
}