Trying to navigate through a set of buttons/widgets


I’m trying to navigate through a set of buttons with a rotary encoder (LV_INDEV_TYPE_ENCODER). This just works fine when putting the buttons in a list object. But in the future I want to add other widgets to the list so I decided to do this with a page object. After adapting the code I can’t navigate through the buttons (LV_KEY_DOWN/LV_KEY_UP) anymore. LV_KEY_ENTER fires the callback on the first focussed button though.

Code to reproduce (LVGL 7.11.0)

This is the code (simplified) that does not work for me.

static lv_obj_t* scr = lv_disp_get_scr_act(NULL);
lv_group_t *group = lv_group_create();
lv_obj_t *page = lv_page_create(scr, NULL);

for (uint8_t i = 0; i < 7; i++) {
  lv_obj_t *button = lv_btn_create(page, NULL);
  lv_obj_set_size(button, 75, 20);
  lv_obj_align(button, NULL, LV_ALIGN_IN_TOP_MID, 0, i * 26 + 14);
  label = lv_label_create(button, NULL);
  lv_label_set_text(label, "Button");

lv_group_add_obj(group, page);


I figured out that changing LV_KEY_DOWN to LV_KEY_NEXT in the indev drv the navigation works again. But I need to keep the LV_KEY_DOWN key. The documentation mentions that the framework will do this automatically in LV_INDEV_TYPE_ENCODER mode. But it doesn’t in my case.