acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
lv_example_keyboard_1.c (1231B)
1 #include "../../lv_examples.h" 2 #if LV_USE_KEYBOARD && LV_BUILD_EXAMPLES 3 4 static void ta_event_cb(lv_event_t * e) 5 { 6 lv_event_code_t code = lv_event_get_code(e); 7 lv_obj_t * ta = lv_event_get_target(e); 8 lv_obj_t * kb = lv_event_get_user_data(e); 9 if(code == LV_EVENT_FOCUSED) { 10 lv_keyboard_set_textarea(kb, ta); 11 lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN); 12 } 13 14 if(code == LV_EVENT_DEFOCUSED) { 15 lv_keyboard_set_textarea(kb, NULL); 16 lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN); 17 } 18 } 19 20 void lv_example_keyboard_1(void) 21 { 22 /*Create a keyboard to use it with an of the text areas*/ 23 lv_obj_t * kb = lv_keyboard_create(lv_scr_act()); 24 25 /*Create a text area. The keyboard will write here*/ 26 lv_obj_t * ta; 27 ta = lv_textarea_create(lv_scr_act()); 28 lv_obj_align(ta, LV_ALIGN_TOP_LEFT, 10, 10); 29 lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb); 30 lv_textarea_set_placeholder_text(ta, "Hello"); 31 lv_obj_set_size(ta, 140, 80); 32 33 ta = lv_textarea_create(lv_scr_act()); 34 lv_obj_align(ta, LV_ALIGN_TOP_RIGHT, -10, 10); 35 lv_obj_add_event_cb(ta, ta_event_cb, LV_EVENT_ALL, kb); 36 lv_obj_set_size(ta, 140, 80); 37 38 lv_keyboard_set_textarea(kb, ta); 39 } 40 #endif