[escher] Fixed TextField bug.

The Statistics apps crashed when navigating the Data table.
 -> Check that the textfield is editing before calling
textFieldShouldFinishEditing.
 -> Changed textLength() to draftTextLength().

Change-Id: Id373a7cd50438303f470abc5bcee7a795c33926a
This commit is contained in:
Léa Saviot
2017-11-27 15:22:48 +01:00
parent 4659d27c80
commit e43bbd38f2
8 changed files with 37 additions and 38 deletions

View File

@@ -83,7 +83,7 @@ void EditExpressionController::didBecomeFirstResponder() {
}
bool EditExpressionController::textFieldDidReceiveEvent(::TextField * textField, Ion::Events::Event event) {
if (textField->textFieldShouldFinishEditing(event) && textField->isEditing() && strlen(textField->text()) == 0 && m_calculationStore->numberOfCalculations() > 0) {
if (textField->isEditing() && textField->textFieldShouldFinishEditing(event) && textField->draftTextLength() == 0 && m_calculationStore->numberOfCalculations() > 0) {
App * calculationApp = (App *)app();
const char * lastTextBody = m_calculationStore->calculationAtIndex(m_calculationStore->numberOfCalculations()-1)->inputText();
m_calculationStore->push(lastTextBody, calculationApp->localContext());