Files
Upsilon/apps/calculation/text_field.cpp
Émilie Feral 151423320e [escher] Resolve bug: specify text field for controller with one only
text buffer

Change-Id: I371c37869e6e48b819cf4af70f7544e2844a3fee
2017-03-29 18:36:47 +02:00

35 lines
949 B
C++

#include "text_field.h"
namespace Calculation {
TextField::TextField(Responder * parentResponder, char * textBuffer, size_t textBufferSize, TextFieldDelegate * delegate) :
::TextField(parentResponder, textBuffer, textBuffer, textBufferSize, delegate, false)
{
setEditing(true);
}
bool TextField::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::Back) {
return false;
}
if (event == Ion::Events::Ans) {
insertTextAtLocation("ans", cursorLocation());
setCursorLocation(cursorLocation() + strlen("ans"));
return true;
}
if (textLength() == 0 &&
(event == Ion::Events::Multiplication ||
event == Ion::Events::Plus ||
event == Ion::Events::Division)) {
if (!isEditing()) {
setEditing(true);
setText("");
}
insertTextAtLocation("ans", cursorLocation());
setCursorLocation(cursorLocation() + strlen("ans"));
}
return(::TextField::handleEvent(event));
}
}