How to create a dynamic roller that draws options from a source

What do you want to achieve?

I have a roller. There are multiple options for people to choose from.

image

These options will be added or deleted as user request. So they should not be hard coded in the UI. Instead, they should be able to import an outside source periodically.

Is there any Squareline Studio (SLS) recommended way to achieve such?

image

Such as using events to dynamically draw this list from a function or something?

Or is this only achievable by changing the LVGL code generated?

What have you tried so far?

Screenshot or video

Others

  • SquareLine Studio version: v1.2.0
  • Operating system: Windows 11
  • Target hardware: AMD Ryzen 7 6000 series

You can use the function:

lv_roller_set_options(ui_rlrParameters, opts, LV_ROLLER_MODE_NORMAL);

Where opts is a string where each option is separated by a newline.

i.e.

char opts[] = { "Item 1\nItem 2\nItem 3\n" };
lv_roller_set_options(ui_rlrParameters, opts, LV_ROLLER_MODE_NORMAL);

Andy

2 Likes

Appreciate your help. I’ll try it out. :+1:

I also recommend this.