Dropdown selected value doesn't change after calling `lv_dropdown_set_selected()`

Description

If I select a value of a dropdown list from code using lv_dropdown_set_selected() the value shown in the main object part doesn’t change.

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

I’m using a Raspberry Pi 3B+ running a custom linux system created with Buildroot, the compiler is gcc v6.3.0 (but also g++ since my project is written in C++). I’m using LVGL v7.7.2.

What do you experience?

If I select a value of a dropdown list from code using lv_dropdown_set_selected() the value shown in the main object part doesn’t change.
As a workaround I have to manually call lv_obj_invalidate() on the dropdown object to force lvgl to repaint it to show the correct value.

What do you expect?

I expect to see the newly selected value in the main part of the dropdown object right after calling lv_dropdown_set_selected() without having to invalidate the object.

Code to reproduce

This is how I set the value

lv_dropdown_set_selected(_ddSource, ddIdx);

// for some reason, after setting the selected option i have to invalidate
// the whole object, otherwise the label won't be refreshed
lv_obj_invalidate(_ddSource);

Your fix looks correct. Thanks for the report!

1 Like

You’re welcome!