V8.0.1 how to hide an object?

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.


In version 6.0.2, lvgl has lv_obj_set_hidden(), and In the V8.0.1 how to hide an object? I dont want to delete objects.

By the way, how to hide the textarea cursor . The style set in 8.0.1 is different from 6.0.2

What MCU/Processor/Board and compiler are you using?

What LVGL version are you using?


What do you want to achieve?

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Simply add or clear the flag as follows, where obj is the object you want to hide or display:

lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);

lv_obj_clear_flag(obj, LV_OBJ_FLAG_HIDDEN);

Iā€™m new to LVGL
could you please write a piece of code to hide cursor of textarea or spinbox
I tried to do it but I still did not succeed

Use method: cursor_blink_anim_cb(void * my_text_area_obj, int32_t show)
show = 0 ā†’ show cursor
show = 1ā€“> hide cursor
For more details see file lv_textarea.c


Thank you for your response. But this is an internal function and I prefer my code to be clean.
I finally did it with this code

lv_obj_t* spinBox = lv_spinbox_create(scr);

static lv_style_t style1;
lv_style_set_bg_opa(&style1, LV_OPA_TRANSP);
lv_style_set_text_opa(&style1, LV_OPA_TRANSP);
lv_obj_add_style(spinBox, &style1, LV_PART_CURSOR);

static lv_style_t style2;
lv_style_set_bg_opa(&style2, LV_OPA_100);
lv_style_set_text_opa(&style2, LV_OPA_100);
lv_obj_add_style(spinBox, &style2, LV_PART_CURSOR | LV_STATE_FOCUS_KEY);
lv_obj_add_style(spinBox, &style2, LV_PART_CURSOR | LV_STATE_FOCUSED);
1 Like