From 56db3a484ec5bf93ea947edbac14767b8a864054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 7 Nov 2018 14:51:43 +0100 Subject: [PATCH] [escher] Fix selection problem in SelectableTableView Scenario that caused a problem: Go to Statistics, then "1", "Right", "Right", "Right", OK. The cell does not draw itself as being edited, but its right neighbour does. --- escher/src/selectable_table_view.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/escher/src/selectable_table_view.cpp b/escher/src/selectable_table_view.cpp index e988b22ae..188da7b7e 100644 --- a/escher/src/selectable_table_view.cpp +++ b/escher/src/selectable_table_view.cpp @@ -78,6 +78,21 @@ bool SelectableTableView::selectCellAtLocation(int i, int j, bool setFirstRespon selectColumn(i); selectRow(j); + if (m_delegate) { + m_delegate->tableViewDidChangeSelection(this, previousX, previousY); + } + + /* We need to scroll: + * - After notifying the delegate. For instance, + * StorageExpressionModelListController 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()); + } + HighlightCell * cell = selectedCell(); if (cell) { // Update first responder @@ -89,12 +104,7 @@ bool SelectableTableView::selectCellAtLocation(int i, int j, bool setFirstRespon } } } - if (m_delegate) { - m_delegate->tableViewDidChangeSelection(this, previousX, previousY); - } - if (selectedRow() >= 0) { - scrollToCell(selectedColumn(), selectedRow()); - } + cell = selectedCell(); if (cell) { cell->setHighlighted(true);