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