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();
}
void Page::onClicked()
{
Keyboard::hide();
}
void Page::onClicked() { Keyboard::hide(false); }
+1 -1
View File
@@ -277,7 +277,7 @@ void TabsGroup::onPressPGDN()
}
#endif
void TabsGroup::onClicked() { Keyboard::hide(); }
void TabsGroup::onClicked() { Keyboard::hide(false); }
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);
if (code == LV_EVENT_READY) {
Keyboard::hide();
Keyboard::hide(false);
} else if (code == LV_EVENT_CANCEL) {
Keyboard::hide();
Keyboard::hide(true);
} else if (code == LV_EVENT_KEY) {
int32_t c = *((int32_t *)lv_event_get_param(e));
if (c == LV_KEY_ESC) {
Keyboard::hide();
Keyboard::hide(false);
}
}
}
static void field_focus_leave(lv_event_t* e)
{
Keyboard::hide();
}
static void field_focus_leave(lv_event_t* e) { Keyboard::hide(false); }
static void _assign_lv_group(lv_group_t* g)
{
@@ -82,7 +79,7 @@ Keyboard::~Keyboard()
if (group) lv_group_del(group);
}
void Keyboard::clearField()
void Keyboard::clearField(bool wasCancelled)
{
TRACE("CLEAR FIELD");
if (keyboard != nullptr) {
@@ -103,8 +100,9 @@ void Keyboard::clearField()
if (obj) {
lv_obj_remove_event_cb(obj, field_focus_leave);
}
field->setEditMode(false);
if (!wasCancelled)
field->setEditMode(false);
field->changeEnd();
field = nullptr;
@@ -116,10 +114,10 @@ void Keyboard::clearField()
}
}
void Keyboard::hide()
void Keyboard::hide(bool wasCancelled)
{
if (activeKeyboard) {
activeKeyboard->clearField();
activeKeyboard->clearField(wasCancelled);
lv_obj_add_flag(activeKeyboard->lvobj, LV_OBJ_FLAG_HIDDEN);
activeKeyboard = nullptr;
}
@@ -129,7 +127,7 @@ bool Keyboard::attachKeyboard()
{
if (activeKeyboard) {
if (activeKeyboard == this) return false;
hide();
hide(false);
}
activeKeyboard = this;
+2 -2
View File
@@ -28,8 +28,8 @@ class Keyboard : public Window
explicit Keyboard(coord_t height);
~Keyboard();
void clearField();
static void hide();
void clearField(bool wasCancelled);
static void hide(bool wasCancelled);
protected:
static Keyboard *activeKeyboard;
+1 -4
View File
@@ -48,10 +48,7 @@ ModalWindowContent::ModalWindowContent(ModalWindow* parent,
{
}
void ModalWindowContent::onClicked()
{
Keyboard::hide();
}
void ModalWindowContent::onClicked() { Keyboard::hide(false); }
void ModalWindowContent::setTitle(const std::string& text)
{