Model Select cosmetics

This commit is contained in:
Bertrand Songis
2019-10-28 18:00:11 +01:00
parent d5c34453d3
commit 6341d0d530
2 changed files with 19 additions and 6 deletions
+3 -5
View File
@@ -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
View File
@@ -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)