lv_dropdown.h

Defines

LV_DROPDOWN_POS_LAST

Functions

lv_obj_t *lv_dropdown_create(lv_obj_t *parent)

Create a drop-down list object

Parameters:

parent -- pointer to an object, it will be the parent of the new drop-down list

Returns:

pointer to the created drop-down list

void lv_dropdown_set_text(lv_obj_t *obj, const char *txt)

Set text of the drop-down list's button. If set to NULL the selected option's text will be displayed on the button. If set to a specific text then that text will be shown regardless of the selected option.

Parameters:
  • obj -- pointer to a drop-down list object

  • txt -- the text as a string (Only its pointer is saved)

void lv_dropdown_set_options(lv_obj_t *obj, const char *options)

Set the options in a drop-down list from a string. The options will be copied and saved in the object so the options can be destroyed after calling this function

Parameters:
  • obj -- pointer to drop-down list object

  • options --

    a string with '

    ' separated options. E.g. "One\nTwo\nThree"

void lv_dropdown_set_options_static(lv_obj_t *obj, const char *options)

Set the options in a drop-down list from a static string (global, static or dynamically allocated). Only the pointer of the option string will be saved.

Parameters:
  • obj -- pointer to drop-down list object

  • options --

    a static string with '

    ' separated options. E.g. "One\nTwo\nThree"

void lv_dropdown_add_option(lv_obj_t *obj, const char *option, uint32_t pos)

Add an options to a drop-down list from a string. Only works for non-static options.

Parameters:
  • obj -- pointer to drop-down list object

  • option --

    a string without '

    '. E.g. "Four"

  • pos -- the insert position, indexed from 0, LV_DROPDOWN_POS_LAST = end of string

void lv_dropdown_clear_options(lv_obj_t *obj)

Clear all options in a drop-down list. Works with both static and dynamic options.

Parameters:

obj -- pointer to drop-down list object

void lv_dropdown_set_selected(lv_obj_t *obj, uint32_t sel_opt)

Set the selected option

Parameters:
  • obj -- pointer to drop-down list object

  • sel_opt -- id of the selected option (0 ... number of option - 1);

void lv_dropdown_set_dir(lv_obj_t *obj, lv_dir_t dir)

Set the direction of the a drop-down list

Parameters:
  • obj -- pointer to a drop-down list object

  • dir -- LV_DIR_LEFT/RIGHT/TOP/BOTTOM

void lv_dropdown_set_symbol(lv_obj_t *obj, const void *symbol)

Set an arrow or other symbol to display when on drop-down list's button. Typically a down caret or arrow.

Note

angle and zoom transformation can be applied if the symbol is an image. E.g. when drop down is checked (opened) rotate the symbol by 180 degree

Parameters:
  • obj -- pointer to drop-down list object

  • symbol -- a text like LV_SYMBOL_DOWN, an image (pointer or path) or NULL to not draw symbol icon

void lv_dropdown_set_selected_highlight(lv_obj_t *obj, bool en)

Set whether the selected option in the list should be highlighted or not

Parameters:
  • obj -- pointer to drop-down list object

  • en -- true: highlight enabled; false: disabled

lv_obj_t *lv_dropdown_get_list(lv_obj_t *obj)

Get the list of a drop-down to allow styling or other modifications

Parameters:

obj -- pointer to a drop-down list object

Returns:

pointer to the list of the drop-down

const char *lv_dropdown_get_text(lv_obj_t *obj)

Get text of the drop-down list's button.

Parameters:

obj -- pointer to a drop-down list object

Returns:

the text as string, NULL if no text

const char *lv_dropdown_get_options(const lv_obj_t *obj)

Get the options of a drop-down list

Parameters:

obj -- pointer to drop-down list object

Returns:

the options separated by '

'-s (E.g. "Option1\nOption2\nOption3")

uint32_t lv_dropdown_get_selected(const lv_obj_t *obj)

Get the index of the selected option

Parameters:

obj -- pointer to drop-down list object

Returns:

index of the selected option (0 ... number of option - 1);

uint32_t lv_dropdown_get_option_count(const lv_obj_t *obj)

Get the total number of options

Parameters:

obj -- pointer to drop-down list object

Returns:

the total number of options in the list

void lv_dropdown_get_selected_str(const lv_obj_t *obj, char *buf, uint32_t buf_size)

Get the current selected option as a string

Parameters:
  • obj -- pointer to drop-down object

  • buf -- pointer to an array to store the string

  • buf_size -- size of buf in bytes. 0: to ignore it.

int32_t lv_dropdown_get_option_index(lv_obj_t *obj, const char *option)

Get the index of an option.

Parameters:
  • obj -- pointer to drop-down object

  • option -- an option as string

Returns:

index of option in the list of all options. -1 if not found.

const char *lv_dropdown_get_symbol(lv_obj_t *obj)

Get the symbol on the drop-down list. Typically a down caret or arrow.

Parameters:

obj -- pointer to drop-down list object

Returns:

the symbol or NULL if not enabled

bool lv_dropdown_get_selected_highlight(lv_obj_t *obj)

Get whether the selected option in the list should be highlighted or not

Parameters:

obj -- pointer to drop-down list object

Returns:

true: highlight enabled; false: disabled

lv_dir_t lv_dropdown_get_dir(const lv_obj_t *obj)

Get the direction of the drop-down list

Parameters:

obj -- pointer to a drop-down list object

Returns:

LV_DIR_LEF/RIGHT/TOP/BOTTOM

void lv_dropdown_open(lv_obj_t *dropdown_obj)

Open the drop.down list

Parameters:

dropdown_obj -- pointer to drop-down list object

void lv_dropdown_close(lv_obj_t *obj)

Close (Collapse) the drop-down list

Parameters:

obj -- pointer to drop-down list object

bool lv_dropdown_is_open(lv_obj_t *obj)

Tells whether the list is opened or not

Parameters:

obj -- pointer to a drop-down list object

Returns:

true if the list os opened

Variables

const lv_obj_class_t lv_dropdown_class
const lv_obj_class_t lv_dropdownlist_class
struct lv_dropdown_t

Public Members

lv_obj_t obj
lv_obj_t *list

The dropped down list

const char *text

Text to display on the dropdown's button

const void *symbol

Arrow or other icon when the drop-down list is closed

char *options

Options in a '

' separated list

uint32_t option_cnt

Number of options

uint32_t sel_opt_id

Index of the currently selected option

uint32_t sel_opt_id_orig

Store the original index on focus

uint32_t pr_opt_id

Index of the currently pressed option

lv_dir_t dir

Direction in which the list should open

uint8_t static_txt

1: Only a pointer is saved in options

uint8_t selected_highlight

1: Make the selected option highlighted in the list

struct lv_dropdown_list_t

Public Members

lv_obj_t obj
lv_obj_t *dropdown