1 #include "../../lv_examples.h"
2 #if LV_USE_KEYBOARD && LV_BUILD_EXAMPLES
3 
lv_example_keyboard_2(void)4 void lv_example_keyboard_2(void)
5 {
6     /*Create an AZERTY keyboard map*/
7     static const char * kb_map[] = {"A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n",
8                                     "Q", "S", "D", "F", "G", "J", "K", "L", "M",  LV_SYMBOL_NEW_LINE, "\n",
9                                     "W", "X", "C", "V", "B", "N", ",", ".", ":", "!", "?", "\n",
10                                     LV_SYMBOL_CLOSE, " ",  " ", " ", LV_SYMBOL_OK, NULL
11                                    };
12 
13     /*Set the relative width of the buttons and other controls*/
14     static const lv_buttonmatrix_ctrl_t kb_ctrl[] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6,
15                                                      4, 4, 4, 4, 4, 4, 4, 4, 4, 6,
16                                                      4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
17                                                      2, LV_BUTTONMATRIX_CTRL_HIDDEN | 2, 6, LV_BUTTONMATRIX_CTRL_HIDDEN | 2, 2
18                                                     };
19 
20     /*Create a keyboard and add the new map as USER_1 mode*/
21     lv_obj_t * kb = lv_keyboard_create(lv_screen_active());
22 
23     lv_keyboard_set_map(kb, LV_KEYBOARD_MODE_USER_1, kb_map, kb_ctrl);
24     lv_keyboard_set_mode(kb, LV_KEYBOARD_MODE_USER_1);
25 
26     /*Create a text area. The keyboard will write here*/
27     lv_obj_t * ta;
28     ta = lv_textarea_create(lv_screen_active());
29     lv_obj_align(ta, LV_ALIGN_TOP_MID, 0, 10);
30     lv_obj_set_size(ta, lv_pct(90), 80);
31     lv_obj_add_state(ta, LV_STATE_FOCUSED);
32 
33     lv_keyboard_set_textarea(kb, ta);
34 }
35 #endif
36