How to set a textarea focuable only when clicked


I have a screen with a lot of textarea as shown in the screenshot below. Whenever I scroll, the textarea I pressed will become focuable.

Currently, I make the keyboard appear only for event LV_EVENT_CLICKED, so that keyboard won’t show up when focus, as shown in the gif below. However, the cursor still appears in the textarea when I scoll through the screen. Is there a better way to simply make the textarea focuable only when clicked?

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


What LVGL version are you using?

lvgl @ 13c96e1

What do you want to achieve?

What have you tried so far?

I tried using the code below to all my textarea as described in Base object (lv_obj) — LVGL documentation. However, it doesn’t seem to work.

lv_obj_add_flag(ta, LV_OBJ_FLAG_CLICK_FOCUSABLE);

Code to reproduce

Screenshot and/or video

Is this issue related: Using combination of key focus and touch/mouse focus exhibits odd behavior · Issue #4034 · lvgl/lvgl · GitHub

I don’t think it is related, since I only use a touchpad. The thing I try to achieve is to set the cursor appears only when clicked.

Preferably, the textarea can be set to focusable only when I click on the textarea. So that the cursor along with the blue background I set in the textarea can appear together.

Otherwise, I will need to set the cursor to appear and disappear manually.
However, textarea doesn’t provide a get function to return lv_obj pointer to the cursor. So I cannot use lv_obj_clear_flag or lv_obj_add_flag to manipulate the appearance of the cursor. The closest thing I can find is:
But, I still don’t know how to style it only when I clicked on the textarea.

Ah, got it.

Do you use groups now? If so all you need to do is using lv_obj_clear_flag(ta, LV_OBJ_FLAG_CLICK_FOCUSABLE); and in the clicked event call lv_group_focus_obj(obj);.

Thanks for your reply! it works exactly what I wanted to do now.