Handling clicks and adjustments in LV_MENU

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

STM32H743

What LVGL version are you using?

8.2 - 8.3

What do you want to achieve?

I want to force the event handler to change only the necessary parameters corresponding to specific menu items.

What have you tried so far?

I used the sample menu code: Menu (lv_menu) — LVGL documentation
In the ‘create_slider’ function I added a line specifying the event handler:

lv_obj_add_event_cb(slider, slider_handler, LV_EVENT_ALL, NULL);

The handler function was created:

static void slider_handler(lv_event_t* e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t* obj = lv_event_get_target(e);
if(code == LV_EVENT_VALUE_CHANGED) {
LED_Bright (true);
}
}

With this approach, there is only one slider handler, and it will work when setting up any slider.
The question is, how do I get this handler to respond only to the desired slider?

I asked the question myself - I will answer myself.

To solve this problem, one knowledgeable person suggested the option of using the user data field in the slider to get this data in the event handler.
In practice, in the function of creating a menu item, when assigning a callback function to an object, a pointer to user data is added (I added a pointer to text):

lv_obj_add_event_cb(slider, slider_handler, LV_EVENT_ALL, (void*)txt);

A string is added to the event handler that allows you to get a pointer passed as user data:

char* txt = lv_event_get_user_data(e);

After that, the handler becomes able to catch the transmitted user data, something like this:

if(strcmp (txt, "KEYS BACKLIGHT\0")==0)
{
    LED_Bright (true);
}