LVGL currently doesn't support return an event handler so it can be removed later.
The only solution is comparing all event dsc user_data.
The issue can be solved by simply storing the event dsc pointer to lvgl internal array and return it to user.
For lua, it needs to remember which events are added from lua side, so when obj is cleaned up, those events can be removed separately with native added events.
Proposal
Use dsc pointer in lvgl internal array, and use lv_array to store events added from lua.
Introduce the problem
LVGL currently doesn't support return an event handler so it can be removed later. The only solution is comparing all event dsc user_data.
The issue can be solved by simply storing the event dsc pointer to lvgl internal array and return it to user.
For lua, it needs to remember which events are added from lua side, so when obj is cleaned up, those events can be removed separately with native added events.
Proposal
Use dsc pointer in lvgl internal array, and use lv_array to store events added from lua.