diff --git a/apps/code/variable_box_controller.cpp b/apps/code/variable_box_controller.cpp index 14908fb71..03103d8f2 100644 --- a/apps/code/variable_box_controller.cpp +++ b/apps/code/variable_box_controller.cpp @@ -136,6 +136,20 @@ void VariableBoxController::willDisplayCellForIndex(HighlightCell * cell, int in static_cast(cell)->setMessage(subtitleMessages[(int)cellOrigin]); } +void VariableBoxController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) { + if (withinTemporarySelection) { + return; + } + const int currentSelectedRow = selectedRow(); + if (typeAtLocation(0, currentSelectedRow) == k_subtitleCellType) { + if (currentSelectedRow == 0) { + t->selectCellAtLocation(0, 1); + } else { + t->selectCellAtLocation(0, selectedRow() + (previousSelectedCellY < currentSelectedRow ? 1 : -1)); + } + } +} + int VariableBoxController::typeAtLocation(int i, int j) { assert(i == 0); return typeAndOriginAtLocation(j); diff --git a/apps/code/variable_box_controller.h b/apps/code/variable_box_controller.h index bc55ab290..3cfb63bf8 100644 --- a/apps/code/variable_box_controller.h +++ b/apps/code/variable_box_controller.h @@ -24,6 +24,8 @@ public: int typeAtLocation(int i, int j) override; /* ListViewDataSource */ void willDisplayCellForIndex(HighlightCell * cell, int index) override; + /* SelectableTableViewDelegate */ + void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) override; /* VariableBoxController */ void loadFunctionsAndVariables(int scriptIndex, const char * textToAutocomplete, int textToAutocompleteLength); diff --git a/escher/include/escher/nested_menu_controller.h b/escher/include/escher/nested_menu_controller.h index 0037d9c90..1cc2ab1ad 100644 --- a/escher/include/escher/nested_menu_controller.h +++ b/escher/include/escher/nested_menu_controller.h @@ -7,7 +7,7 @@ #include #include -class NestedMenuController : public StackViewController, public ListViewDataSource, public SelectableTableViewDataSource { +class NestedMenuController : public StackViewController, public ListViewDataSource, public SelectableTableViewDataSource, public SelectableTableViewDelegate { public: NestedMenuController(Responder * parentResponder, I18n::Message title = (I18n::Message)0); void setSender(InputEventHandler * sender) { m_sender = sender; } diff --git a/escher/src/nested_menu_controller.cpp b/escher/src/nested_menu_controller.cpp index 44b80456a..12d0263ae 100644 --- a/escher/src/nested_menu_controller.cpp +++ b/escher/src/nested_menu_controller.cpp @@ -90,7 +90,7 @@ void NestedMenuController::ListController::setFirstSelectedRow(int firstSelected NestedMenuController::NestedMenuController(Responder * parentResponder, I18n::Message title) : StackViewController(parentResponder, &m_listController, KDColorWhite, Palette::PurpleBright, Palette::PurpleDark), - m_selectableTableView(&m_listController, this, this), + m_selectableTableView(&m_listController, this, this, this), m_listController(this, &m_selectableTableView, title), m_sender(nullptr) {