fix(color): Closing keyboard also closes underlying page (#4354)

This commit is contained in:
philmoz
2023-11-27 21:43:02 +10:00
committed by GitHub
parent aa62221fc2
commit cf6169bdef
5 changed files with 16 additions and 24 deletions
+1 -4
View File
@@ -93,7 +93,4 @@ void Page::onCancel()
deleteLater(); deleteLater();
} }
void Page::onClicked() void Page::onClicked() { Keyboard::hide(false); }
{
Keyboard::hide();
}
+1 -1
View File
@@ -277,7 +277,7 @@ void TabsGroup::onPressPGDN()
} }
#endif #endif
void TabsGroup::onClicked() { Keyboard::hide(); } void TabsGroup::onClicked() { Keyboard::hide(false); }
void TabsGroup::onCancel() { deleteLater(); } void TabsGroup::onCancel() { deleteLater(); }
+11 -13
View File
@@ -27,21 +27,18 @@ static void keyboard_event_cb(lv_event_t * e)
{ {
auto code = lv_event_get_code(e); auto code = lv_event_get_code(e);
if (code == LV_EVENT_READY) { if (code == LV_EVENT_READY) {
Keyboard::hide(); Keyboard::hide(false);
} else if (code == LV_EVENT_CANCEL) { } else if (code == LV_EVENT_CANCEL) {
Keyboard::hide(); Keyboard::hide(true);
} else if (code == LV_EVENT_KEY) { } else if (code == LV_EVENT_KEY) {
int32_t c = *((int32_t *)lv_event_get_param(e)); int32_t c = *((int32_t *)lv_event_get_param(e));
if (c == LV_KEY_ESC) { if (c == LV_KEY_ESC) {
Keyboard::hide(); Keyboard::hide(false);
} }
} }
} }
static void field_focus_leave(lv_event_t* e) static void field_focus_leave(lv_event_t* e) { Keyboard::hide(false); }
{
Keyboard::hide();
}
static void _assign_lv_group(lv_group_t* g) static void _assign_lv_group(lv_group_t* g)
{ {
@@ -82,7 +79,7 @@ Keyboard::~Keyboard()
if (group) lv_group_del(group); if (group) lv_group_del(group);
} }
void Keyboard::clearField() void Keyboard::clearField(bool wasCancelled)
{ {
TRACE("CLEAR FIELD"); TRACE("CLEAR FIELD");
if (keyboard != nullptr) { if (keyboard != nullptr) {
@@ -103,8 +100,9 @@ void Keyboard::clearField()
if (obj) { if (obj) {
lv_obj_remove_event_cb(obj, field_focus_leave); lv_obj_remove_event_cb(obj, field_focus_leave);
} }
field->setEditMode(false); if (!wasCancelled)
field->setEditMode(false);
field->changeEnd(); field->changeEnd();
field = nullptr; field = nullptr;
@@ -116,10 +114,10 @@ void Keyboard::clearField()
} }
} }
void Keyboard::hide() void Keyboard::hide(bool wasCancelled)
{ {
if (activeKeyboard) { if (activeKeyboard) {
activeKeyboard->clearField(); activeKeyboard->clearField(wasCancelled);
lv_obj_add_flag(activeKeyboard->lvobj, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(activeKeyboard->lvobj, LV_OBJ_FLAG_HIDDEN);
activeKeyboard = nullptr; activeKeyboard = nullptr;
} }
@@ -129,7 +127,7 @@ bool Keyboard::attachKeyboard()
{ {
if (activeKeyboard) { if (activeKeyboard) {
if (activeKeyboard == this) return false; if (activeKeyboard == this) return false;
hide(); hide(false);
} }
activeKeyboard = this; activeKeyboard = this;
+2 -2
View File
@@ -28,8 +28,8 @@ class Keyboard : public Window
explicit Keyboard(coord_t height); explicit Keyboard(coord_t height);
~Keyboard(); ~Keyboard();
void clearField(); void clearField(bool wasCancelled);
static void hide(); static void hide(bool wasCancelled);
protected: protected:
static Keyboard *activeKeyboard; static Keyboard *activeKeyboard;
+1 -4
View File
@@ -48,10 +48,7 @@ ModalWindowContent::ModalWindowContent(ModalWindow* parent,
{ {
} }
void ModalWindowContent::onClicked() void ModalWindowContent::onClicked() { Keyboard::hide(false); }
{
Keyboard::hide();
}
void ModalWindowContent::setTitle(const std::string& text) void ModalWindowContent::setTitle(const std::string& text)
{ {