mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[apps/graph]Handle user escaping the function renaming with "Back"
This commit is contained in:
@@ -71,6 +71,18 @@ bool StorageListController::textFieldDidFinishEditing(TextField * textField, con
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StorageListController::textFieldDidAbortEditing(TextField * textField) {
|
||||
StorageFunction * function = m_functionStore->modelAtIndex(selectedRow());
|
||||
setFunctionNameInTextField(function, textField);
|
||||
m_selectableTableView.selectedCell()->setHighlighted(true);
|
||||
app()->setFirstResponder(&m_selectableTableView);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StorageListController::textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) {
|
||||
return event == Ion::Events::Up || event == Ion::Events::Down || Shared::TextFieldDelegate::textFieldShouldFinishEditing(textField, event);
|
||||
}
|
||||
|
||||
StorageListParameterController * StorageListController::parameterController() {
|
||||
return &m_parameterController;
|
||||
}
|
||||
@@ -90,13 +102,11 @@ HighlightCell * StorageListController::expressionCells(int index) {
|
||||
}
|
||||
|
||||
void StorageListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) {
|
||||
TextFieldFunctionTitleCell * myFunctionCell = (TextFieldFunctionTitleCell *)cell;
|
||||
TextFieldFunctionTitleCell * titleCell = static_cast<TextFieldFunctionTitleCell *>(cell);
|
||||
StorageFunction * function = modelStore()->modelForRecord(modelStore()->recordAtIndex(j));
|
||||
char bufferName[BufferTextView::k_maxNumberOfChar];
|
||||
function->nameWithArgument(bufferName, BufferTextView::k_maxNumberOfChar, modelStore()->symbol());
|
||||
myFunctionCell->setText(bufferName);
|
||||
setFunctionNameInTextField(function, titleCell->textField());
|
||||
KDColor functionNameColor = function->isActive() ? function->color() : Palette::GreyDark;
|
||||
myFunctionCell->setColor(functionNameColor);
|
||||
titleCell->setColor(functionNameColor);
|
||||
}
|
||||
|
||||
void StorageListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) {
|
||||
@@ -107,4 +117,10 @@ void StorageListController::willDisplayExpressionCellAtIndex(HighlightCell * cel
|
||||
myCell->setTextColor(textColor);
|
||||
}
|
||||
|
||||
void StorageListController::setFunctionNameInTextField(StorageFunction * function, TextField * textField) {
|
||||
char bufferName[BufferTextView::k_maxNumberOfChar];
|
||||
function->nameWithArgument(bufferName, BufferTextView::k_maxNumberOfChar, m_functionStore->symbol());
|
||||
textField->setText(bufferName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@ public:
|
||||
StorageListController(Responder * parentResponder, ButtonRowController * header, ButtonRowController * footer);
|
||||
const char * title() override;
|
||||
void renameSelectedFunction();
|
||||
// TextFieldDelegate
|
||||
bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
|
||||
bool textFieldDidAbortEditing(TextField * textField) override;
|
||||
bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) override;
|
||||
private:
|
||||
constexpr static int k_maxNumberOfDisplayableRows = 5;
|
||||
Shared::StorageListParameterController * parameterController() override;
|
||||
@@ -28,6 +31,7 @@ private:
|
||||
Shared::TextFieldDelegateApp * textFieldDelegateApp() override {
|
||||
return static_cast<Shared::TextFieldDelegateApp *>(app());
|
||||
}
|
||||
void setFunctionNameInTextField(Shared::StorageFunction * function, TextField * textField);
|
||||
TextFieldFunctionTitleCell m_functionTitleCells[k_maxNumberOfDisplayableRows];
|
||||
Shared::FunctionExpressionCell m_expressionCells[k_maxNumberOfDisplayableRows];
|
||||
ListParameterController m_parameterController;
|
||||
|
||||
@@ -11,6 +11,7 @@ class StorageListController;
|
||||
class TextFieldFunctionTitleCell : public Shared::FunctionTitleCell, public Responder {
|
||||
public:
|
||||
TextFieldFunctionTitleCell(StorageListController * listController, Orientation orientation = Orientation::VerticalIndicator, KDText::FontSize size = KDText::FontSize::Large);
|
||||
TextField * textField() { return &m_textField; }
|
||||
void setEditing(bool editing);
|
||||
void setEven(bool even) override;
|
||||
void setHighlighted(bool highlight) override;
|
||||
|
||||
Reference in New Issue
Block a user