From 1da2f23914a2f500e2bacacfc76d5b2d6b4441f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 26 Jun 2020 15:59:00 +0200 Subject: [PATCH] [escher] SelectableTableView: fix delegate notification when deselecting table view This fixes the following bug: input 1.2/2, OK, up, down, the exact ouput is still displayed but should have toggled --- escher/src/selectable_table_view.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/escher/src/selectable_table_view.cpp b/escher/src/selectable_table_view.cpp index 9b4aab505..b77f46011 100644 --- a/escher/src/selectable_table_view.cpp +++ b/escher/src/selectable_table_view.cpp @@ -71,6 +71,7 @@ void SelectableTableView::deselectTable(bool withinTemporarySelection) { selectRow(-1); if (m_delegate) { m_delegate->tableViewDidChangeSelection(this, previousSelectedCellX, previousSelectedCellY, withinTemporarySelection); + m_delegate->tableViewDidChangeSelectionAndDidScroll(this, previousSelectedCellX, previousSelectedCellY, withinTemporarySelection); } } @@ -87,17 +88,20 @@ bool SelectableTableView::selectCellAtLocation(int i, int j, bool setFirstRespon selectColumn(i); selectRow(j); + /* The delegate is notified: + * - after changing the selected cell but before scrolling: for instance, + * ExpressionModelListController needs to update its memoized cell before + * being able to scroll; + * - after scrolling: for instance, the calculation history table might + * change its cell content when selected (outup toggling, ellipsis toggling) + * and thus need to access the right used cell - which is defined only + * after scrolling. + */ + if (m_delegate) { m_delegate->tableViewDidChangeSelection(this, previousX, previousY, withinTemporarySelection); } - /* We need to scroll: - * - After notifying the delegate. For instance, - * ExpressionModelListController needs to update its memoized cell - * height values before any scroll. - * - Before setting the first responder. If the first responder is a view, it - * might change during the scroll. */ - if (selectedRow() >= 0) { scrollToCell(selectedColumn(), selectedRow()); }