添加数字键盘

This commit is contained in:
sc committed 2026-03-14 23:30:04 +08:00
1 parent e8966f0764
commit 4e4dfbb640
4 files changed
+51 -1

No files matched your search

@@ -7276,7 +7276,7 @@ void setup_scr_screen(lv_ui *ui)
lv_textarea_set_accepted_chars(ui->screen_machine_id_rt, "0123456789");
lv_textarea_set_max_length(ui->screen_machine_id_rt, 2);
#if LV_USE_KEYBOARD != 0 || LV_USE_ZH_KEYBOARD != 0
lv_obj_add_event_cb(ui->screen_machine_id_rt, ta_event_cb, LV_EVENT_ALL, ui->g_kb_top_layer);
lv_obj_add_event_cb(ui->screen_machine_id_rt, ta_event_cb_NUMBER, LV_EVENT_ALL, ui->g_kb_top_layer);
#endif
lv_obj_set_pos(ui->screen_machine_id_rt, 150, 10);
lv_obj_set_size(ui->screen_machine_id_rt, 200, 50);
@@ -42,6 +42,37 @@ __attribute__((unused)) void ta_event_cb (lv_event_t *e) {
if (code == LV_EVENT_CANCEL || code == LV_EVENT_DEFOCUSED)
{
#if LV_USE_ZH_KEYBOARD != 0
lv_zh_keyboard_set_textarea(kb, ta);
#endif
#if LV_USE_KEYBOARD != 0
lv_keyboard_set_textarea(kb, ta);
#endif
lv_obj_move_background(kb);
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
}
}
__attribute__((unused)) void ta_event_cb_NUMBER (lv_event_t *e) {
lv_event_code_t code = lv_event_get_code(e);
#if LV_USE_KEYBOARD || LV_USE_ZH_KEYBOARD
lv_obj_t *ta = lv_event_get_target(e);
#endif
lv_obj_t *kb = lv_event_get_user_data(e);
if (code == LV_EVENT_FOCUSED || code == LV_EVENT_CLICKED)
{
#if LV_USE_ZH_KEYBOARD != 0
lv_zh_keyboard_set_textarea(kb, ta);
#endif
#if LV_USE_KEYBOARD != 0
lv_keyboard_set_textarea(kb, ta);
lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_NUMBER);
#endif
lv_obj_move_foreground(kb);
lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
}
if (code == LV_EVENT_CANCEL || code == LV_EVENT_DEFOCUSED)
{
#if LV_USE_ZH_KEYBOARD != 0
lv_zh_keyboard_set_textarea(kb, ta);
#endif
@@ -18,6 +18,7 @@ extern "C" {
__attribute__((unused)) void kb_event_cb(lv_event_t *e);
__attribute__((unused)) void ta_event_cb(lv_event_t *e);
__attribute__((unused)) void ta_event_cb_NUMBER (lv_event_t *e);
#if LV_USE_ANALOGCLOCK != 0
void clock_count(int *hour, int *min, int *sec);
#endif