diff --git a/CYD-Klipper/src/ui/ip_setup.cpp b/CYD-Klipper/src/ui/ip_setup.cpp index 1419972..cdcd44c 100644 --- a/CYD-Klipper/src/ui/ip_setup.cpp +++ b/CYD-Klipper/src/ui/ip_setup.cpp @@ -62,6 +62,20 @@ static void keyboard_event_ip_entry(lv_event_t * e) { lv_obj_t * ta = lv_event_get_target(e); lv_obj_t * kb = (lv_obj_t *)lv_event_get_user_data(e); + if (code == LV_EVENT_FOCUSED || code == LV_EVENT_DEFOCUSED && ta != NULL) + { + // make sure we alter the keymap before taking actions that might + // destroy the keyboard + if (lv_obj_has_flag(ta, LV_OBJ_FLAG_USER_1)) + { + lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_USER_1); + } + else + { + lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUMBER); + } + } + if(code == LV_EVENT_FOCUSED) { lv_keyboard_set_textarea(kb, ta); lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN); @@ -94,15 +108,6 @@ static void keyboard_event_ip_entry(lv_event_t * e) { { return; } - - if (lv_obj_has_flag(ta, LV_OBJ_FLAG_USER_1)) - { - lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_USER_1); - } - else - { - lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUMBER); - } } static void keyboard_event_auth_entry(lv_event_t * e) {