Adding button Events to Gui (lvgl 8.3.6)

Hi, I am trying to get events to work on a simple project by force sending a keypad click (LV_KEY_RIGHT) to the indev function as below:-

void lv_port_indev_init(void)
{

  • keypad_init();*

  • lv_indev_drv_init(&indev_drv);*

  • indev_drv.type = LV_INDEV_TYPE_KEYPAD;*

  • indev_drv.read_cb = keypad_read;*

  • indev_keypad = lv_indev_drv_register(&indev_drv);*

}

static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)

{
data->state = LV_INDEV_STATE_PR;
data->key = LV_KEY_RIGHT;
}

I have then made a simple ui in squareline with 2 buttons with 2 events (event trigger is on the back panel itself) from which the 2nd button should change state to pressed when “LV_KEY_RIGHT” is called, but the screen just sits there and doesn’t change state? I have also tried force sending “lv_event_send(&ui_Panel2, LV_KEY_RIGHT , NULL);” and “lv_event_send(&ui_Button2, LV_STATE_PRESSED , NULL);” which still doesn’t change the button state? I am at a loss on how to get input driven events to work on the ui?

Have you added the indev to the default group (created with lv_group_t * g = lv_group_create() and lv_group_set_default(g) ) with the call lv_ivdev_set_group( indev_keypad, g) ?
Note: If you send a state-setting LVGL event to a widget it won’t necessarily cause the assigned event as if it was pressed by hand.)