diff --git a/apps/solver/list_controller.cpp b/apps/solver/list_controller.cpp index 768c7f579..774ac498c 100644 --- a/apps/solver/list_controller.cpp +++ b/apps/solver/list_controller.cpp @@ -125,10 +125,11 @@ bool layoutRepresentsAnEquality(Poincare::Layout l) { bool ListController::textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) { if (textField->isEditing() && textField->shouldFinishEditing(event)) { - if (!textRepresentsAnEquality(textField->text())) { - textField->handleEvent(Ion::Events::ShiftRight); + const char * text = textField->text(); + if (!textRepresentsAnEquality(text)) { + textField->setCursorLocation(text + strlen(text)); textField->handleEventWithText("=0"); - if (!textRepresentsAnEquality(textField->text())) { + if (!textRepresentsAnEquality(text)) { Container::activeApp()->displayWarning(I18n::Message::RequireEquation); return true; } @@ -143,7 +144,7 @@ bool ListController::textFieldDidReceiveEvent(TextField * textField, Ion::Events bool ListController::layoutFieldDidReceiveEvent(LayoutField * layoutField, Ion::Events::Event event) { if (layoutField->isEditing() && layoutField->shouldFinishEditing(event)) { if (!layoutRepresentsAnEquality(layoutField->layout())) { - layoutField->handleEvent(Ion::Events::ShiftRight); + layoutField->putCursorRightOfLayout(); layoutField->handleEventWithText("=0"); if (!layoutRepresentsAnEquality(layoutField->layout())) { Container::activeApp()->displayWarning(I18n::Message::RequireEquation); diff --git a/escher/include/escher/layout_field.h b/escher/include/escher/layout_field.h index 9237f63bc..518b849b9 100644 --- a/escher/include/escher/layout_field.h +++ b/escher/include/escher/layout_field.h @@ -30,6 +30,7 @@ public: bool hasText() const { return layout().hasText(); } Poincare::Layout layout() const { return m_contentView.expressionView()->layout(); } CodePoint XNTCodePoint(CodePoint defaultXNTCodePoint) override; + void putCursorRightOfLayout(); // ScrollableView void setBackgroundColor(KDColor c) override { diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index 92802363d..a9984846f 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -295,6 +295,10 @@ CodePoint LayoutField::XNTCodePoint(CodePoint defaultXNTCodePoint) { return defaultXNTCodePoint; } +void LayoutField::putCursorRightOfLayout() { + m_contentView.setCursor(LayoutCursor(m_contentView.expressionView()->layout(), LayoutCursor::Position::Right)); +} + void LayoutField::reload(KDSize previousSize) { layout().invalidAllSizesPositionsAndBaselines(); KDSize newSize = minimalSizeForOptimalDisplay();