[escher/layout_field] Fix EmptyLayout disappearance

Scenario :
In the calculation app, write 1, press Enter.
       •|
Write ---
       2
Then go up. The empty layout on top of the fraction disappears.
This commit is contained in:
Léa Saviot
2019-07-31 10:15:31 +02:00
committed by Émilie Feral
parent a7d3df39c3
commit ce15bc202d

View File

@@ -156,18 +156,20 @@ bool LayoutField::handleEvent(Ion::Events::Event event) {
shouldRecomputeLayout = true;
didHandleEvent = true;
}
if (didHandleEvent) {
shouldRecomputeLayout = m_contentView.cursor()->hideEmptyLayoutIfNeeded() || shouldRecomputeLayout;
if (!shouldRecomputeLayout) {
m_contentView.cursorPositionChanged();
scrollToCursor();
} else {
reload(previousSize);
}
return true;
/* Hide empty layout only if the layout is being edited, otherwise the cursor
* is not visible so any empty layout should be visible. */
bool didHideLayouts = isEditing() && m_contentView.cursor()->hideEmptyLayoutIfNeeded();
if (!didHandleEvent) {
return false;
}
m_contentView.cursor()->hideEmptyLayoutIfNeeded();
return false;
shouldRecomputeLayout = didHideLayouts || shouldRecomputeLayout;
if (!shouldRecomputeLayout) {
m_contentView.cursorPositionChanged();
scrollToCursor();
} else {
reload(previousSize);
}
return true;
}
bool LayoutField::privateHandleEvent(Ion::Events::Event event) {