diff --git a/apps/shared/list_controller.cpp b/apps/shared/list_controller.cpp index 80bc1ef65..9ca2c5f28 100644 --- a/apps/shared/list_controller.cpp +++ b/apps/shared/list_controller.cpp @@ -249,6 +249,12 @@ void ListController::willExitResponderChain(Responder * nextFirstResponder) { } } +void ListController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) { + if (m_functionStore->numberOfFunctions() < m_functionStore->maxNumberOfFunctions() && selectedRow() == numberOfRows() - 1 && selectedColumn() == 0) { + t->selectCellAtLocation(previousSelectedCellX, previousSelectedCellY); + } +} + StackViewController * ListController::stackController() const{ return (StackViewController *)(parentResponder()->parentResponder()->parentResponder()); } @@ -294,7 +300,7 @@ bool ListController::removeFunctionRow(Function * function) { View * ListController::loadView() { m_emptyCell = new EvenOddCell(); m_addNewFunction = new NewFunctionCell(m_addNewMessage); - return new SelectableTableView(this, this, 0, 0, 0, 0, 0, 0, this, nullptr, false, true); + return new SelectableTableView(this, this, 0, 0, 0, 0, 0, 0, this, this, false, true); } void ListController::unloadView(View * view) { diff --git a/apps/shared/list_controller.h b/apps/shared/list_controller.h index 02b6354cb..2c1ec1344 100644 --- a/apps/shared/list_controller.h +++ b/apps/shared/list_controller.h @@ -9,7 +9,7 @@ namespace Shared { -class ListController : public DynamicViewController, public ButtonRowDelegate, public TableViewDataSource, public SelectableTableViewDataSource { +class ListController : public DynamicViewController, public ButtonRowDelegate, public TableViewDataSource, public SelectableTableViewDataSource, public SelectableTableViewDelegate { public: ListController(Responder * parentResponder, FunctionStore * functionStore, ButtonRowController * header, ButtonRowController * footer, I18n::Message text); int numberOfColumns() override; @@ -28,6 +28,7 @@ public: bool handleEvent(Ion::Events::Event event) override; void didEnterResponderChain(Responder * previousFirstResponder) override; void willExitResponderChain(Responder * nextFirstResponder) override; + void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) override; protected: static constexpr KDCoordinate k_emptyRowHeight = 50; StackViewController * stackController() const;