[apps/code] Do not select subtitles in the variable box

This commit is contained in:
Léa Saviot
2020-04-15 17:48:59 +02:00
committed by Émilie Feral
parent 0d6016116d
commit 33d8d10286
4 changed files with 18 additions and 2 deletions

View File

@@ -136,6 +136,20 @@ void VariableBoxController::willDisplayCellForIndex(HighlightCell * cell, int in
static_cast<MessageTableCell *>(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);

View File

@@ -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);

View File

@@ -7,7 +7,7 @@
#include <escher/selectable_table_view.h>
#include <escher/stack_view_controller.h>
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; }

View File

@@ -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)
{