[escher] LayoutField: reset selection when the field should finish

editing

This fixes the following bug: in solver, input Matrix(Matrix()) and select the
inner Matrix. When handling "OK" event, the "=0" is inserted at a wrong
position leading to a crash !
This commit is contained in:
Émilie Feral
2020-02-03 14:34:53 +01:00
committed by Léa Saviot
parent 2ae435a628
commit 879843ce2b
2 changed files with 9 additions and 3 deletions

View File

@@ -41,9 +41,7 @@ public:
/* Responder */
bool handleEventWithText(const char * text, bool indentation = false, bool forceCursorRightOfText = false) override;
bool handleEvent(Ion::Events::Event event) override;
bool shouldFinishEditing(Ion::Events::Event event) override { // TODO REMOVE ?
return m_delegate->layoutFieldShouldFinishEditing(this, event);
}
bool shouldFinishEditing(Ion::Events::Event event) override; // TODO REMOVE ?
// Selection
bool resetSelection() { return m_contentView.resetSelection(); }

View File

@@ -369,6 +369,14 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool
return true;
}
bool LayoutField::shouldFinishEditing(Ion::Events::Event event) {
if (m_delegate->layoutFieldShouldFinishEditing(this, event)) {
resetSelection();
return true;
}
return false;
}
bool LayoutField::handleEvent(Ion::Events::Event event) {
bool didHandleEvent = false;
KDSize previousSize = minimalSizeForOptimalDisplay();