1. fixed checkbox focus on touch
2. fixed crash if you edit a textbox and close the simu. TextEdit changeEnd() wasnt checking lvgl for validity 3. removed dead code in new TextEdit onTouchEnd()
This commit is contained in:
committed by
Raphael Coeffic
parent
0429341528
commit
6a8707fb69
+12
@@ -85,3 +85,15 @@ void CheckBox::onEvent(event_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
bool CheckBox::onTouchEnd(coord_t x, coord_t y)
|
||||
{
|
||||
if (!hasFocus()) {
|
||||
setFocus(SET_FOCUS_DEFAULT);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ class CheckBox : public FormField {
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||
#endif
|
||||
|
||||
uint8_t getValue() const
|
||||
{
|
||||
return _getValue();
|
||||
|
||||
+12
-11
@@ -261,18 +261,19 @@ bool TextEdit::onTouchEnd(coord_t x, coord_t y)
|
||||
TextKeyboard::show(this);
|
||||
#endif
|
||||
|
||||
coord_t rest = x;
|
||||
for (cursorPos = 0; cursorPos < length; cursorPos++) {
|
||||
char c = value[cursorPos];
|
||||
if (c == '\0')
|
||||
break;
|
||||
uint8_t w = getCharWidth(c, fontspecsTable[0]) + 1;
|
||||
if (rest < w)
|
||||
break;
|
||||
rest -= w;
|
||||
}
|
||||
// coord_t rest = x;
|
||||
// for (cursorPos = 0; cursorPos < length; cursorPos++) {
|
||||
// char c = value[cursorPos];
|
||||
// if (c == '\0')
|
||||
// break;
|
||||
// uint8_t w = getCharWidth(c, fontspecsTable[0]) + 1;
|
||||
// if (rest < w)
|
||||
// break;
|
||||
// rest -= w;
|
||||
// }
|
||||
|
||||
// invalidate();
|
||||
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
+3
-1
@@ -67,7 +67,9 @@ class TextEdit : public FormField {
|
||||
|
||||
void changeEnd(bool forceChanged = false) override
|
||||
{
|
||||
strncpy(value, lv_textarea_get_text(lvobj), length);
|
||||
if (lvobj != nullptr)
|
||||
strncpy(value, lv_textarea_get_text(lvobj), length);
|
||||
|
||||
cursorPos = 0;
|
||||
if (changed || forceChanged) {
|
||||
changed = false;
|
||||
|
||||
Reference in New Issue
Block a user