Object with state LV_STATE_DISABLED, becomes invisible

Description

I use three external keys, as input device LV_INDEV_TYPE_ENCODER. I create a group for each screen, and add individual objects to the group. When the object has the state LV_STATE_DISABLED, after it is no longer visible on the screen (because another element is focused), that disputed object is no longer visible on the screen, it’s like it’s hidden when I try to focus it again. I forcibly clear the flag LV_OBJ_FLAG_HIDDEN of the object, but it doesn’t help. Please, help?

Additionally, I would like to change the behavior of the Checkbox object.
It is necessary to focus on the object with the keys, press the ENTER key, and then press the enter key again to change the state. Now it is necessary to hold the ENTER key to leave the object editing mode. Then we can use the PREV/NEXT keys to focus the objects in the group again.

I want the following behavior:
I use the PREV/NEXT keys to focus different objects in the group, and with the ENTER key I want to change the state CHECKED/UNCHECKED. I don’t want to enter editing mode with the ENTER key, nor do I want to hold the ENTER key to exit that mode

I want to increase the check mark, when the object is CHECKED.

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

ESP32-C3, ESP-IDF v5.0

What LVGL version are you using?

v8.3.9

Code to reproduce

void lv_example_checkbox_1(void)
{
    lv_obj_set_flex_flow(lv_scr_act(), LV_FLEX_FLOW_COLUMN);
    lv_obj_set_flex_align(lv_scr_act(), LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER);

    lv_obj_t * cb;
    cb = lv_checkbox_create(lv_scr_act());
    lv_checkbox_set_text(cb, "Apple");
    lv_obj_add_state(cb, LV_STATE_DISABLED);
    lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);

    cb = lv_checkbox_create(lv_scr_act());
    lv_checkbox_set_text(cb, "Banana");
    lv_obj_add_state(cb, LV_STATE_CHECKED);
    lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);

    cb = lv_checkbox_create(lv_scr_act());
    lv_checkbox_set_text(cb, "Lemon");
    lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);

    cb = lv_checkbox_create(lv_scr_act());
    lv_checkbox_set_text(cb, "Melon\nand a new line");
    lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
    lv_obj_update_layout(cb);
}

Screenshot and/or video


Pls, help: @kisvegabor

Tnx :slight_smile:

Hi,

I’ve tested the DISABLED issue, but I couldn’t reproduce it :frowning: I have no idea how can it be hardware related, but could you try it a simulator on PC?

Regarding the edit mode behaviour, maybe you need an KEYPAD input device instead with

  • LV_KEY_NEXT
  • LV_KEY_PREV
  • LV_KEY_ENTER

keys.

And an official example on the site:

https://docs.lvgl.io/8.3/widgets/core/checkbox.html#simple-checkboxes

behaves like that.
Can only focus “Apple” and “Banana”

Example: There are several objects (or groups of objects), which are located one below the other. Only a few objects are visible on the screen (due to the small screen size)
The object has the flag “LV_OBJ_FLAG_SCROLL_ON_FOCUS”.
And if the object has the “LV_STATE_DISABLED” state, such an object cannot be added to the group, and thus cannot be focused, and only the object will be visible on the screen if it is focused.

The key is that there are more objects than are visible on the screen. When we focus on objects within a group of objects, it is not possible to focus on an object with the “LV_STATE_DISABLED” state, so it cannot be displayed on the screen.

Three external keys are used, implemented as encoder.

Video: Video link