# lv_roller.h (/api/widgets/roller/lv_roller_h)



<RelatedHeaders name="lv_roller_private.h" isPrivate="false" />

<ApiSummary functions="11" enums="2" variables="1" />

Functions [#functions]

<ApiTabs items="[&#x22;Setters (4)&#x22;,&#x22;Getters (5)&#x22;,&#x22;Other (2)&#x22;]">
  <ApiTab value="Setters (4)">
    <ApiMember kind="function" name="lv_roller_set_options" file="widgets/roller/lv_roller.h" line="73" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L73">
      lv_roller_set_options [#lv_roller_set_options]

      Set the options on a roller

      ```c title=" " lineNumbers=1
      void lv_roller_set_options(lv_obj_t *obj, const char *options, lv_roller_mode_t mode)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name      | Type                                             | Description                                                            |
      | --------- | ------------------------------------------------ | ---------------------------------------------------------------------- |
      | `obj`     | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to roller object                                               |
      | `options` | `const char *`                                   | a string with '\<br/><br />' separated options. E.g. "One\nTwo\nThree" |
      | `mode`    | <ApiLink name="lv_roller_mode_t" />              | `LV_ROLLER_MODE_NORMAL` or `LV_ROLLER_MODE_INFINITE`                   |
    </ApiMember>

    <ApiMember kind="function" name="lv_roller_set_selected" file="widgets/roller/lv_roller.h" line="81" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L81">
      lv_roller_set_selected [#lv_roller_set_selected]

      Set the selected option

      ```c title=" " lineNumbers=1
      void lv_roller_set_selected(lv_obj_t *obj, uint32_t sel_opt, lv_anim_enable_t anim)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name      | Type                                             | Description                                                     |
      | --------- | ------------------------------------------------ | --------------------------------------------------------------- |
      | `obj`     | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to a roller object                                      |
      | `sel_opt` | <ApiLink name="uint32_t" />                      | index of the selected option (0 ... number of option - 1);      |
      | `anim`    | <ApiLink name="lv_anim_enable_t" />              | LV\_ANIM\_ON: set with animation; LV\_ANIM\_OFF set immediately |
    </ApiMember>

    <ApiMember kind="function" name="lv_roller_set_selected_str" file="widgets/roller/lv_roller.h" line="90" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L90">
      lv_roller_set_selected_str [#lv_roller_set_selected_str]

      Sets the given string as the selection on the roller. Does not alter the current selection on failure.

      ```c title=" " lineNumbers=1
      bool lv_roller_set_selected_str(lv_obj_t *obj, const char *sel_opt, lv_anim_enable_t anim)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name      | Type                                             | Description                                                     |
      | --------- | ------------------------------------------------ | --------------------------------------------------------------- |
      | `obj`     | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to roller object                                        |
      | `sel_opt` | `const char *`                                   | pointer to the string you want to set as an option              |
      | `anim`    | <ApiLink name="lv_anim_enable_t" />              | LV\_ANIM\_ON: set with animation; LV\_ANIM\_OFF set immediately |

      **Returns:** <ApiLink name="bool" /> — `true` if set successfully and `false` if the given string does not exist as an option in the roller
    </ApiMember>

    <ApiMember kind="function" name="lv_roller_set_visible_row_count" file="widgets/roller/lv_roller.h" line="97" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L97">
      lv_roller_set_visible_row_count [#lv_roller_set_visible_row_count]

      Set the height to show the given number of rows (options)

      ```c title=" " lineNumbers=1
      void lv_roller_set_visible_row_count(lv_obj_t *obj, uint32_t row_cnt)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name      | Type                                             | Description                    |
      | --------- | ------------------------------------------------ | ------------------------------ |
      | `obj`     | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to a roller object     |
      | `row_cnt` | <ApiLink name="uint32_t" />                      | number of desired visible rows |
    </ApiMember>
  </ApiTab>

  <ApiTab value="Getters (5)">
    <ApiMember kind="function" name="lv_roller_get_selected" file="widgets/roller/lv_roller.h" line="108" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L108">
      lv_roller_get_selected [#lv_roller_get_selected]

      Get the index of the selected option

      ```c title=" " lineNumbers=1
      uint32_t lv_roller_get_selected(const lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                                   | Description                |
      | ----- | ------------------------------------------------------ | -------------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to a roller object |

      **Returns:** <ApiLink name="uint32_t" /> — index of the selected option (0 ... number of option - 1);
    </ApiMember>

    <ApiMember kind="function" name="lv_roller_get_selected_str" file="widgets/roller/lv_roller.h" line="116" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L116">
      lv_roller_get_selected_str [#lv_roller_get_selected_str]

      Get the current selected option as a string.

      ```c title=" " lineNumbers=1
      void lv_roller_get_selected_str(const lv_obj_t *obj, char *buf, uint32_t buf_size)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name       | Type                                                   | Description                              |
      | ---------- | ------------------------------------------------------ | ---------------------------------------- |
      | `obj`      | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to roller object                 |
      | `buf`      | `char *`                                               | pointer to an array to store the string  |
      | `buf_size` | <ApiLink name="uint32_t" />                            | size of `buf` in bytes. 0: to ignore it. |
    </ApiMember>

    <ApiMember kind="function" name="lv_roller_get_options" file="widgets/roller/lv_roller.h" line="123" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L123">
      lv_roller_get_options [#lv_roller_get_options]

      Get the options of a roller

      ```c title=" " lineNumbers=1
      const char * lv_roller_get_options(const lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                                   | Description              |
      | ----- | ------------------------------------------------------ | ------------------------ |
      | `obj` | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to roller object |

      **Returns:** `const char *` — the options separated by '\<br/>
      '-s (E.g. "Option1\nOption2\nOption3")
    </ApiMember>

    <ApiMember kind="function" name="lv_roller_get_option_count" file="widgets/roller/lv_roller.h" line="130" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L130">
      lv_roller_get_option_count [#lv_roller_get_option_count]

      Get the total number of options

      ```c title=" " lineNumbers=1
      uint32_t lv_roller_get_option_count(const lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                                   | Description                |
      | ----- | ------------------------------------------------------ | -------------------------- |
      | `obj` | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to a roller object |

      **Returns:** <ApiLink name="uint32_t" /> — the total number of options
    </ApiMember>

    <ApiMember kind="function" name="lv_roller_get_option_str" file="widgets/roller/lv_roller.h" line="140" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L140">
      lv_roller_get_option_str [#lv_roller_get_option_str]

      Get an option as a string.

      ```c title=" " lineNumbers=1
      lv_result_t lv_roller_get_option_str(const lv_obj_t *obj, uint32_t option, char *buf, uint32_t buf_size)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name       | Type                                                   | Description                              |
      | ---------- | ------------------------------------------------------ | ---------------------------------------- |
      | `obj`      | <ApiLink name="lv_obj_t" display="const lv_obj_t *" /> | pointer to roller object                 |
      | `option`   | <ApiLink name="uint32_t" />                            | index of chosen option                   |
      | `buf`      | `char *`                                               | pointer to an array to store the string  |
      | `buf_size` | <ApiLink name="uint32_t" />                            | size of `buf` in bytes. 0: to ignore it. |

      **Returns:** <ApiLink name="lv_result_t" /> — LV\_RESULT\_OK if option found
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (2)">
    <ApiMember kind="function" name="lv_roller_create" file="widgets/roller/lv_roller.h" line="61" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L61">
      lv_roller_create [#lv_roller_create]

      Create a roller object

      ```c title=" " lineNumbers=1
      lv_obj_t * lv_roller_create(lv_obj_t *parent)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name     | Type                                             | Description                                                    |
      | -------- | ------------------------------------------------ | -------------------------------------------------------------- |
      | `parent` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object, it will be the parent of the new roller. |

      **Returns:** <ApiLink name="lv_obj_t" display="lv_obj_t *" /> — pointer to the created roller
    </ApiMember>

    <ApiMember kind="function" name="lv_roller_bind_value" file="widgets/roller/lv_roller.h" line="149" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L149">
      lv_roller_bind_value [#lv_roller_bind_value]

      Bind an integer Subject to a Roller's value.

      ```c title=" " lineNumbers=1
      lv_observer_t * lv_roller_bind_value(lv_obj_t *obj, lv_subject_t *subject)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name      | Type                                                     | Description        |
      | --------- | -------------------------------------------------------- | ------------------ |
      | `obj`     | <ApiLink name="lv_obj_t" display="lv_obj_t *" />         | pointer to Roller  |
      | `subject` | <ApiLink name="lv_subject_t" display="lv_subject_t *" /> | pointer to Subject |

      **Returns:** <ApiLink name="lv_observer_t" display="lv_observer_t *" /> — pointer to newly-created Observer
    </ApiMember>
  </ApiTab>
</ApiTabs>

Enums [#enums]

<ApiMember kind="enum" name="lv_roller_mode_t" file="widgets/roller/lv_roller.h" line="36" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L36">
  lv_roller_mode_t [#lv_roller_mode_t]

  Roller mode.

  | Name                      | Description                                          |
  | ------------------------- | ---------------------------------------------------- |
  | `LV_ROLLER_MODE_NORMAL`   | Normal mode (roller ends at the end of the options). |
  | `LV_ROLLER_MODE_INFINITE` | Infinite mode (roller can be scrolled forever).      |
</ApiMember>

<TypeUsedBy name="lv_roller_mode_t" count="1">
  * `lv_roller_set_options` — param `mode`
</TypeUsedBy>

<ApiMember kind="enum" name="_lv_property_roller_id_t" file="widgets/roller/lv_roller.h" line="42" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L42">
  \_lv_property_roller_id_t [#_lv_property_roller_id_t]

  | Name                                   | Value                                                                               |
  | -------------------------------------- | ----------------------------------------------------------------------------------- |
  | `LV_PROPERTY_ROLLER_OPTIONS`           | `(LV_PROPERTY_ROLLER_START + ((int) 0 )) \| (( 7  ) <<  28 ) \| ((  1   ) <<  24 )` |
  | `LV_PROPERTY_ROLLER_SELECTED`          | `(LV_PROPERTY_ROLLER_START + ((int) 1 )) \| (( 1  ) <<  28 ) \| ((  1   ) <<  24 )` |
  | `LV_PROPERTY_ROLLER_VISIBLE_ROW_COUNT` | `(LV_PROPERTY_ROLLER_START + ((int) 2 )) \| ((  1   ) <<  28 )`                     |
  | `LV_PROPERTY_ROLLER_END`               |                                                                                     |
</ApiMember>

Variables [#variables]

<ApiMember kind="variable" name="lv_roller_class" file="widgets/roller/lv_roller.h" line="50" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/roller/lv_roller.h#L50">
  lv_roller_class [#lv_roller_class]

  ```c title=" " lineNumbers=1
  const lv_obj_class_t lv_roller_class
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_obj.h&#x22;, &#x22;lv_label.h&#x22;]" includedBy="[&#x22;lv_roller_private.h&#x22;]" transitiveIncludes="[&#x22;lv_anim.h&#x22;, &#x22;lv_area.h&#x22;, &#x22;lv_array.h&#x22;, &#x22;lv_assert.h&#x22;, &#x22;lv_bidi.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_conf_internal.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_display.h&#x22;, &#x22;lv_draw.h&#x22;, &#x22;lv_draw_arc.h&#x22;, &#x22;lv_draw_blur.h&#x22;, &#x22;lv_draw_buf.h&#x22;, &#x22;lv_draw_image.h&#x22;, &#x22;lv_draw_label.h&#x22;, &#x22;lv_draw_line.h&#x22;, &#x22;lv_draw_rect.h&#x22;, &#x22;lv_draw_triangle.h&#x22;, &#x22;lv_event.h&#x22;, &#x22;lv_ext_data.h&#x22;, &#x22;lv_flex.h&#x22;, &#x22;lv_font.h&#x22;, &#x22;lv_fs.h&#x22;, &#x22;lv_grad.h&#x22;, &#x22;lv_grid.h&#x22;, &#x22;lv_group.h&#x22;, &#x22;lv_image_decoder.h&#x22;, &#x22;lv_image_dsc.h&#x22;, &#x22;lv_indev.h&#x22;, &#x22;lv_layout.h&#x22;, &#x22;lv_ll.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_math.h&#x22;, &#x22;lv_matrix.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_obj_class.h&#x22;, &#x22;lv_obj_draw.h&#x22;, &#x22;lv_obj_event.h&#x22;, &#x22;lv_obj_pos.h&#x22;, &#x22;lv_obj_property.h&#x22;, &#x22;lv_obj_property_names.h&#x22;, &#x22;lv_obj_scroll.h&#x22;, &#x22;lv_obj_style.h&#x22;, &#x22;lv_obj_style_gen.h&#x22;, &#x22;lv_obj_tree.h&#x22;, &#x22;lv_observer.h&#x22;, &#x22;lv_palette.h&#x22;, &#x22;lv_profiler.h&#x22;, &#x22;lv_profiler_builtin.h&#x22;, &#x22;lv_sprintf.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_style.h&#x22;, &#x22;lv_style_gen.h&#x22;, &#x22;lv_style_properties.h&#x22;, &#x22;lv_symbol_def.h&#x22;, &#x22;lv_text.h&#x22;, &#x22;lv_tick.h&#x22;, &#x22;lv_timer.h&#x22;, &#x22;lv_types.h&#x22;]" />
