Item in the dropdown list is not selected

Description

Clicking on an item in the dropdown list always displays the last item.
It was confirmed that lv_dropdown_get_selected_str() is continuously called by the events (LV_EVENT_PRESSED, LV_EVENT_SHORT_CLICKED, LV_EVENT_RELEASED) occurring while clicking the dropdown list. Is this normal operation?
When the lv_dropdown_get_selected_str() function is called by LV_EVENT_VALUE_CHANGED when another item is clicked, the sel_opt_id_orig value does not change and always points to the last index.
I’d appreciate if you let me know why this is happening and how to fix it.

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

STM32F767IIT
Custom board
FreeRTOS v10.2.1

What LVGL version are you using?

7.10.1

What do you want to achieve?

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:

static void event_handler1(lv_obj_t * obj, lv_event_t event)
{
    if(event == LV_EVENT_VALUE_CHANGED) {
        char buf[32];
        lv_dropdown_get_selected_str(obj, buf, sizeof(buf));
    }
}

static void GUI_SelectProgram(void)
{
	touch_init();
    // Create a window

	if(win == NULL)
	{
		screen = lv_obj_create(lv_scr_act(), NULL);
		lv_obj_set_size(screen, 480, 320);
		win = lv_win_create(screen, NULL);
	}

    // window
    lv_win_set_title(win, "Select Program");
    lv_coord_t header_height = lv_win_get_header_height(win);
    lv_win_set_content_size(win, 480, 320-header_height);

    /*Create a normal drop down list*/
    ddlist = lv_dropdown_create(lv_scr_act(), NULL);
    lv_dropdown_set_options(ddlist, "Apple\n"
            "Banana\n"
            "Orange");

    lv_obj_align(ddlist, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);
    lv_obj_set_event_cb(ddlist, event_handler1);

    while(true)
    {
        vTaskDelay(1);
        lv_task_handler();

        if (CURR_GUI_STATE != GUI_STATE_MAIN){
        	lv_win_clean(win);
            break;
        }
    }
}

Screenshot and/or video


ddlist-error

Dropdowns in v7 don’t have any issues like this that I’m aware of (and the dropdown in lv_demo_widgets seems to work fine). Does the same happen in the PC simulator?

Since we used the example you provided as is, the pc simulation should work. The problem is that the dropdown list doesn’t work well in my board environment, and I have to find out the cause. What I have checked so far is that the variable sel_opt_id_orig used in the lv_dropdown_get_selected_str() function does not get the value properly. I don’t know why this is so.

If it works in the simulator, I suspect it’s not an LVGL bug (but it still could be).

Is it possible that your touchscreen driver has an issue and sends the previous coordinates in some edge cases?

I found the cause.
The moment it is released after selecting the dropdown list, the x and y coordinates return to their initial values and leave the screen area. So it is assumed that only the last item is always displayed.
The moment it is released, it reads the x and y coordinates of the previous pressed state, so it operates normally.

Thank embeddedt.

I am having same problem. What is the solution ?