mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/solver] Fix addition of "=0" to equations
ShiftRight no longer puts the cursor at the end of the text/layout.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user