How can new widget get "LV_EVENT_KEY" event?


I made custom widget and I want to handle this widget by key event.
so. I defined lv_custom_class like bleow,

const lv_obj_class_t lv_custom_class = {
.constructor_cb = lv_custom_constructor,
.destructor_cb = lv_custom_destructor,
.event_cb = lv_custom_event,
.width_def = LV_PCT(100),

static void lv_custom_event(const lv_obj_class_t * class_p, lv_event_t * e)
lv_event_code_t code = lv_event_get_code(e);
if( code == LV_EVENT_KEY)
// do something

but, custom widget doesn’t receive “LV_EVENT_KEY” event.
is there any pre-condition for custom widget to get KEY event?

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

custom widget to get “LV_EVENT_KEY” event

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:
please refer to above code.

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

As my understanding, the object which is focused can receive KEY event.
How can I add new custom widget to default group?

help me. (T.T)

Default group

Interactive widgets - such as buttons, checkboxes, sliders, etc. - can be automatically added to a default group.
Just create a group with lv_group_t * g = lv_group_create(); and set the default group with lv_group_set_default(g);

found it

add below statement to lv_custom_class structure