[ion] Update the Event model

Change-Id: I41a53caeb7dd8a15e7934f49675f6a53be8fe7be
This commit is contained in:
Romain Goyet
2016-11-09 17:31:26 +01:00
committed by Émilie Feral
parent b220ed5dd8
commit b87f06e3a2
34 changed files with 862 additions and 565 deletions

View File

@@ -69,28 +69,26 @@ void EditExpressionController::setTextBody(const char * text) {
}
bool EditExpressionController::handleEvent(Ion::Events::Event event) {
switch (event) {
case Ion::Events::Event::ENTER:
{
Calculation calculation = Calculation();
App * calculationApp = (App *)app();
calculation.setContent(textBody(), calculationApp->evaluateContext());
m_calculationStore->push(&calculation);
m_historyController->reload();
m_contentView.mainView()->scrollToCell(0, m_historyController->numberOfRows()-1);
m_contentView.textField()->setText("");
return true;
}
case Ion::Events::Event::ESC:
return true;
case Ion::Events::Event::UP_ARROW:
if (m_calculationStore->numberOfCalculations() > 0) {
app()->setFirstResponder(m_historyController);
}
return true;
default:
return false;
if (event == Ion::Events::OK) {
Calculation calculation = Calculation();
App * calculationApp = (App *)app();
calculation.setContent(textBody(), calculationApp->evaluateContext());
m_calculationStore->push(&calculation);
m_historyController->reload();
m_contentView.mainView()->scrollToCell(0, m_historyController->numberOfRows()-1);
m_contentView.textField()->setText("");
return true;
}
if (event == Ion::Events::Back) {
return true;
}
if (event == Ion::Events::Up) {
if (m_calculationStore->numberOfCalculations() > 0) {
app()->setFirstResponder(m_historyController);
}
return true;
}
return false;
}
void EditExpressionController::didBecomeFirstResponder() {