How to set and change button focus on MsgBox, using hardware buttons

What do you want to achieve?

What have you tried so far?

I create a MsgBox and display it on the screen. How to set the initial focus to a button? How to change the focus of the button, if the button is pressed?

Screenshot or video

Others

  • SquareLine Studio version: v8.3.9
  • Operating system: Windows 10 Pro
  • Target hardware: Intel(R) Core™ i7-9700

Code:

void CreateMsgBoxSet(void)
{
    
static const char* btns[] = { "Yes", "No", "" };
    mboxSet = lv_msgbox_create(NULL, NULL, "Confirm selection.", btns, NULL);
    lv_obj_set_style_text_font(mboxSet, &lv_font_montserrat_26, LV_PART_MAIN| LV_STATE_DEFAULT);

    lv_obj_set_style_bg_color(mboxSet, lv_palette_main(LV_PALETTE_BLUE_GREY), LV_PART_MAIN);
    lv_obj_add_event_cb(mboxSet, event_cbMsgBox, LV_EVENT_ALL, NULL);
    lv_obj_align(mboxSet, LV_ALIGN_CENTER, 0, 0);
    lv_group_add_obj(g, mboxSet);
}

We hope we got your intention correctly. For what you want to achieve (getting focus on pressed button) this code-snippet might give some idea:
lv_btnmatrix_set_selected_btn(lv_msgbox_get_btns(mboxSet), 1);

(As for the hardware-buttons you may check the ‘groups’ section of LVGL documentation. Or if that doesn’t answer your question please explain how hardware buttons are involved in your situation.)

This account is inactive for me. We describe the problem in detail here: