feat(dropdown): keep the list on open/close for simpler styling

So far it was deleted on close, now it's just hidden/unhidden
This commit is contained in:
Gabor Kiss-Vamosi
2021-11-23 13:30:16 +01:00
parent 8b709936b5
commit 9d3134b66e
3 changed files with 49 additions and 35 deletions

View File

@@ -29,8 +29,8 @@ The button goes to `LV_STATE_CHECKED` when it's opened.
- `LV_PART_SCROLLBAR` The scrollbar background, border, shadow properties and width (for its own width) and right padding for the spacing on the right.
- `LV_PART_SELECTED` Refers to the currently pressed, checked or pressed+checked option. Also uses the typical background properties.
As list does not exist when the drop-down list is closed it's not possible to simply add styles to it.
Instead, add an event handler to the button for `LV_EVENT_READY` (triggered when the list is opened) and add styles to the list in it like this:
The list is hidden/shown on open/close. To add styles to it use `lv_dropdown_get_list(dropdown)` to get the list object. For example:
```c
lv_obj_t * list = lv_dropdown_get_list(dropdown) /*Get the list*/
lv_obj_add_style(list, &my_style, ...) /*Add the styles to the list*/}`