[escher][apps] CHange textField API

Change-Id: I766d153b7f7429473f297707a08358051123accc
This commit is contained in:
Émilie Feral
2016-12-13 16:00:55 +01:00
parent fed6664b42
commit 8c284ba34f
35 changed files with 470 additions and 378 deletions

View File

@@ -119,19 +119,10 @@ void ListController::configureFunction(Function * function) {
stack->push(&m_parameterController);
}
void ListController::editExpression(FunctionExpressionView * functionCell, const char * initialText) {
char initialTextContent[255];
int cursorDelta = 0;
if (initialText) {
strlcpy(initialTextContent, initialText, sizeof(initialTextContent));
cursorDelta = strlen(initialText) > 1 ? -1 : 0;
} else {
strlcpy(initialTextContent, functionCell->function()->text(), sizeof(initialTextContent));
}
int cursorLocation = strlen(initialTextContent) + cursorDelta;
void ListController::editExpression(FunctionExpressionView * functionCell, Ion::Events::Event event) {
App * myApp = (App *)app();
InputViewController * inputController = myApp->inputViewController();
inputController->edit(this, initialTextContent, cursorLocation, functionCell,
inputController->edit(this, event, functionCell,
[](void * context, void * sender){
FunctionExpressionView * myCell = (FunctionExpressionView *) context;
Function * myFunction = myCell->function();
@@ -154,15 +145,11 @@ bool ListController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK) {
return handleEnter();
}
if (event == Ion::Events::XNT && m_selectableTableView.selectedColumn() == 1){
FunctionExpressionView * functionCell = (FunctionExpressionView *)(m_selectableTableView.cellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()));
editExpression(functionCell, "x");
}
if (!event.hasText() || m_selectableTableView.selectedColumn() == 0) {
if ((!event.hasText() && event != Ion::Events::XNT) || m_selectableTableView.selectedColumn() == 0) {
return false;
}
FunctionExpressionView * functionCell = (FunctionExpressionView *)(m_selectableTableView.cellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()));
editExpression(functionCell, event.text());
editExpression(functionCell, event);
return true;
}
@@ -188,7 +175,7 @@ bool ListController::handleEnter() {
return false;
}
FunctionExpressionView * functionCell = (FunctionExpressionView *)(m_selectableTableView.cellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()));
editExpression(functionCell);
editExpression(functionCell, Ion::Events::OK);
return true;
}
default: