From 00a0dd182fb5b21bce7e9c96a5cd9959e79bef8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 28 Oct 2016 09:48:41 +0200 Subject: [PATCH] [apps/calculation] Correct bug: set the right cell first responder Change-Id: Iafee70a6a3bcf59c60efb4575b044b19fa5c1db4 --- apps/calculation/history_controller.cpp | 5 +++-- escher/include/escher/selectable_table_view.h | 1 + escher/src/selectable_table_view.cpp | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/calculation/history_controller.cpp b/apps/calculation/history_controller.cpp index 7000c73ac..bb3af652f 100644 --- a/apps/calculation/history_controller.cpp +++ b/apps/calculation/history_controller.cpp @@ -61,8 +61,9 @@ bool HistoryController::handleEvent(Ion::Events::Event event) { } void HistoryController::tableViewDidChangeSelection(SelectableTableView * t) { - m_calculationHistory[t->selectedRow()].setParentResponder(t); - app()->setFirstResponder(&m_calculationHistory[t->selectedRow()]); + HistoryViewCell * selectedCell = (HistoryViewCell *)(t->selectedCell()); + selectedCell->setParentResponder(t); + app()->setFirstResponder(selectedCell); } int HistoryController::numberOfRows() { diff --git a/escher/include/escher/selectable_table_view.h b/escher/include/escher/selectable_table_view.h index 24b736a4d..e28aff81d 100644 --- a/escher/include/escher/selectable_table_view.h +++ b/escher/include/escher/selectable_table_view.h @@ -24,6 +24,7 @@ public: virtual void didBecomeFirstResponder() override; void deselectTable(); bool selectCellAtLocation(int i, int j); + TableViewCell * selectedCell(); private: int m_selectedCellX; int m_selectedCellY; diff --git a/escher/src/selectable_table_view.cpp b/escher/src/selectable_table_view.cpp index a206d513d..236912d58 100644 --- a/escher/src/selectable_table_view.cpp +++ b/escher/src/selectable_table_view.cpp @@ -55,6 +55,10 @@ bool SelectableTableView::selectCellAtLocation(int i, int j) { return true; } +TableViewCell * SelectableTableView::selectedCell() { + return cellAtLocation(m_selectedCellX, m_selectedCellY); +} + bool SelectableTableView::handleEvent(Ion::Events::Event event) { switch (event) { case Ion::Events::Event::DOWN_ARROW: