lv_label.h

API reference for lv_label.h

Report on GitHub
See Also: Private HeaderThis header has a companion private implementation with internal data structures.lv_label_private.h

Functions

lv_label_set_text

Set a new text for a label. Memory will be allocated to store the text by the label.

 
void lv_label_set_text(lv_obj_t *obj, const char *text)
Parameters
NameTypeDescription
objlv_obj_t *pointer to a label object
textconst char *'\0' terminated character string. NULL to refresh with the current text.

If LV_USE_ARABIC_PERSIAN_CHARS is enabled the text will be modified to have the correct Arabic characters in it.

lv_label_set_text_fmt

Set a new formatted text for a label. Memory will be allocated to store the text by the label.

 
void lv_label_set_text_fmt(lv_obj_t *obj, const char *fmt,...)
Parameters
NameTypeDescription
objlv_obj_t *pointer to a label object
fmtconst char *printf-like format string Example: lv_label_set_text_fmt(label1, "%d user", user_num);
...

If LV_USE_ARABIC_PERSIAN_CHARS is enabled the text will be modified to have the correct Arabic characters in it.

lv_label_set_text_vfmt

Set a new formatted text for a label. Memory will be allocated to store the text by the label. Example:

 
va_list args;
va_start(args, fmt);
lv_label_set_text_vfmt(label1, fmt, args);
va_end(args);
 
void lv_label_set_text_vfmt(lv_obj_t *obj, const char *fmt, va_list args)
Parameters
NameTypeDescription
objlv_obj_t *pointer to a label object
fmtconst char *printf-like format string
argsva_listvariadic arguments list

It ignores LV_USE_ARABIC_PERSIAN_CHARS

lv_label_set_text_static

Set a static text. It will not be saved by the label so the 'text' variable has to be 'alive' while the label exists.

 
void lv_label_set_text_static(lv_obj_t *obj, const char *text)
Parameters
NameTypeDescription
objlv_obj_t *pointer to a label object
textconst char *pointer to a text. NULL to refresh with the current text.

It ignores LV_USE_ARABIC_PERSIAN_CHARS

lv_label_set_long_mode

Set the behavior of the label with text longer than the object size

 
void lv_label_set_long_mode(lv_obj_t *obj, lv_label_long_mode_t long_mode)
Parameters
NameTypeDescription
objlv_obj_t *pointer to a label object
long_modelv_label_long_mode_tthe new mode from 'lv_label_long_mode' enum. In LV_LONG_WRAP/DOT/SCROLL/SCROLL_CIRC the size of the label should be set AFTER this function

lv_label_set_text_selection_start

Set where text selection should start

 
void lv_label_set_text_selection_start(lv_obj_t *obj, uint32_t index)
Parameters
NameTypeDescription
objlv_obj_t *pointer to a label object
indexuint32_tcharacter index from where selection should start. LV_LABEL_TEXT_SELECTION_OFF for no selection

lv_label_set_text_selection_end

Set where text selection should end

 
void lv_label_set_text_selection_end(lv_obj_t *obj, uint32_t index)
Parameters
NameTypeDescription
objlv_obj_t *pointer to a label object
indexuint32_tcharacter index where selection should end. LV_LABEL_TEXT_SELECTION_OFF for no selection

lv_label_set_recolor

Enable the recoloring by in-line commands

 
void lv_label_set_recolor(lv_obj_t *obj, bool en)
Parameters
NameTypeDescription
objlv_obj_t *pointer to a label object
enbooltrue: enable recoloring, false: disable Example: "This is a #ff0000 red# word"

lv_label_set_translation_tag

Assign a translation tag for this label. Memory will be allocated to store the tag by the label. The label text will automatically update when the language is changed via lv_translation_set_language.

 
void lv_label_set_translation_tag(lv_obj_t *obj, const char *tag)
Parameters
NameTypeDescription
objlv_obj_t *pointer to a label object
tagconst char *'\0' terminated character string.

Enums

lv_label_long_mode_t

Long mode behaviors. Used in 'lv_label_ext_t'

NameDescription
LV_LABEL_LONG_MODE_WRAPKeep the object width, wrap lines longer than object width and expand the object height
LV_LABEL_LONG_MODE_DOTSKeep the size and write dots at the end if the text is too long
LV_LABEL_LONG_MODE_SCROLLKeep the size and roll the text back and forth
LV_LABEL_LONG_MODE_SCROLL_CIRCULARKeep the size and roll the text circularly
LV_LABEL_LONG_MODE_CLIPKeep the size and clip the text out of it
Used by 1 function
  • lv_label_set_long_mode — param long_mode

_lv_property_label_id_t

NameValue
LV_PROPERTY_LABEL_TEXT(LV_PROPERTY_LABEL_START + ((int) 0 )) | (( 7 ) << 28 )
LV_PROPERTY_LABEL_LONG_MODE(LV_PROPERTY_LABEL_START + ((int) 1 )) | (( 1 ) << 28 )
LV_PROPERTY_LABEL_TEXT_SELECTION_START(LV_PROPERTY_LABEL_START + ((int) 2 )) | (( 1 ) << 28 )
LV_PROPERTY_LABEL_TEXT_SELECTION_END(LV_PROPERTY_LABEL_START + ((int) 3 )) | (( 1 ) << 28 )
LV_PROPERTY_LABEL_END

Macros

LV_LABEL_DOT_NUM

 
#define LV_LABEL_DOT_NUM 3

LV_LABEL_POS_LAST

 
#define LV_LABEL_POS_LAST 0xFFFF

LV_LABEL_TEXT_SELECTION_OFF

 
#define LV_LABEL_TEXT_SELECTION_OFF LV_DRAW_LABEL_NO_TXT_SEL

LV_LABEL_DEFAULT_TEXT

 
#define LV_LABEL_DEFAULT_TEXT "Text"

Variables

lv_label_class

 
const lv_obj_class_t lv_label_class

Dependencies

How is this guide?

Last updated on

On this page