Model Select cosmetics
This commit is contained in:
+3
-5
@@ -135,14 +135,13 @@ void TextEdit::onEvent(event_t event)
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trim();
|
changeEnd();
|
||||||
FormField::onEvent(event);
|
FormField::onEvent(event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVT_KEY_BREAK(KEY_EXIT):
|
case EVT_KEY_BREAK(KEY_EXIT):
|
||||||
cursorPos = 0;
|
changeEnd();
|
||||||
trim();
|
|
||||||
FormField::onEvent(event);
|
FormField::onEvent(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -211,8 +210,7 @@ void TextEdit::onFocusLost()
|
|||||||
TextKeyboard::hide();
|
TextKeyboard::hide();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
trim();
|
changeEnd();
|
||||||
cursorPos = 0;
|
|
||||||
|
|
||||||
// TODO storageDirty(...);
|
// TODO storageDirty(...);
|
||||||
FormField::onFocusLost();
|
FormField::onFocusLost();
|
||||||
|
|||||||
+16
-1
@@ -26,13 +26,14 @@ class TextEdit : public FormField {
|
|||||||
friend class TextKeyboard;
|
friend class TextKeyboard;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextEdit(Window * parent, const rect_t &rect, char * value, uint8_t length, LcdFlags flags = 0) :
|
TextEdit(Window * parent, const rect_t & rect, char * value, uint8_t length, LcdFlags flags = 0) :
|
||||||
FormField(parent, rect),
|
FormField(parent, rect),
|
||||||
value(value),
|
value(value),
|
||||||
length(length)
|
length(length)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() override
|
std::string getName() override
|
||||||
{
|
{
|
||||||
@@ -40,6 +41,11 @@ class TextEdit : public FormField {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void setChangeHandler(std::function<void()> handler)
|
||||||
|
{
|
||||||
|
changeHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t getMaxLength()
|
uint8_t getMaxLength()
|
||||||
{
|
{
|
||||||
return length;
|
return length;
|
||||||
@@ -64,9 +70,18 @@ class TextEdit : public FormField {
|
|||||||
char * value;
|
char * value;
|
||||||
uint8_t length;
|
uint8_t length;
|
||||||
uint8_t cursorPos = 0;
|
uint8_t cursorPos = 0;
|
||||||
|
std::function<void()> changeHandler = nullptr;
|
||||||
|
|
||||||
void trim();
|
void trim();
|
||||||
|
|
||||||
|
void changeEnd()
|
||||||
|
{
|
||||||
|
cursorPos = 0;
|
||||||
|
trim();
|
||||||
|
if (changeHandler)
|
||||||
|
changeHandler();
|
||||||
|
}
|
||||||
|
|
||||||
static uint8_t getNextChar(uint8_t c)
|
static uint8_t getNextChar(uint8_t c)
|
||||||
{
|
{
|
||||||
if (c == ' ' || c == 0)
|
if (c == ' ' || c == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user