Files
Upsilon/apps/calculation/text_field.cpp
Émilie Feral f51ae5db12 [kandinsky] Introduce two fonts: small font and large font
Change-Id: I502dfa88d627b09ac5af76155140af63547025cd
2017-01-27 11:14:01 +01:00

44 lines
1.1 KiB
C++

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