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_menu_2.c (1575B)

      1 #include "../../lv_examples.h"
      2 #if LV_USE_MENU && LV_USE_MSGBOX && LV_BUILD_EXAMPLES
      3 
      4 static void back_event_handler(lv_event_t * e)
      5 {
      6     lv_obj_t * obj = lv_event_get_target(e);
      7     lv_obj_t * menu = lv_event_get_user_data(e);
      8 
      9     if(lv_menu_back_btn_is_root(menu, obj)) {
     10         lv_obj_t * mbox1 = lv_msgbox_create(NULL, "Hello", "Root back btn click.", NULL, true);
     11         lv_obj_center(mbox1);
     12     }
     13 }
     14 
     15 void lv_example_menu_2(void)
     16 {
     17     lv_obj_t * menu = lv_menu_create(lv_scr_act());
     18     lv_menu_set_mode_root_back_btn(menu, LV_MENU_ROOT_BACK_BTN_ENABLED);
     19     lv_obj_add_event_cb(menu, back_event_handler, LV_EVENT_CLICKED, menu);
     20     lv_obj_set_size(menu, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));
     21     lv_obj_center(menu);
     22 
     23     lv_obj_t * cont;
     24     lv_obj_t * label;
     25 
     26     /*Create a sub page*/
     27     lv_obj_t * sub_page = lv_menu_page_create(menu, NULL);
     28 
     29     cont = lv_menu_cont_create(sub_page);
     30     label = lv_label_create(cont);
     31     lv_label_set_text(label, "Hello, I am hiding here");
     32 
     33     /*Create a main page*/
     34     lv_obj_t * main_page = lv_menu_page_create(menu, NULL);
     35 
     36     cont = lv_menu_cont_create(main_page);
     37     label = lv_label_create(cont);
     38     lv_label_set_text(label, "Item 1");
     39 
     40     cont = lv_menu_cont_create(main_page);
     41     label = lv_label_create(cont);
     42     lv_label_set_text(label, "Item 2");
     43 
     44     cont = lv_menu_cont_create(main_page);
     45     label = lv_label_create(cont);
     46     lv_label_set_text(label, "Item 3 (Click me!)");
     47     lv_menu_set_load_page_event(menu, cont, sub_page);
     48 
     49     lv_menu_set_page(menu, main_page);
     50 }
     51 
     52 #endif