What MCU/Processor/Board and compiler are you using?
ARM STM32
What LVGL version are you using?
7.7
What do you want to achieve?
I want to be able to disable a label, and see it in another color. the label is beside a widget that is disabled, so I want both to appear as disabled.
What have you tried so far?
I have disable the label object, but the label remains the same. I have searched in the theme properties any way to add the disabled color of the labels, but I have not fund it
Code to reproduce
I have used
lv_obj_set_state(label, LV_STATE_DISABLED);
I have also changed the properties of the theme, to see if it works, but I’m not able to modify it properly
If I change COLOR_SCR_TEXT, I can see that the labels change their color in the screens. But I was expecting that id I addded the LV_STATE_DISABLED property, the COLOR_SCR_TEXT_DIS (current set to RED) color would apply when the label is disabled.Am I wrong? Is it possible to do it that way?
It’d be great to see a more complete code snippet to reproduce the issue. I believe adding style to the screen wasn’t work becase there are some other objects between the screen and the label from where the label gets its color. E.g. screen->container->label. In this case the label’s style is inherited from the container.
To solve it on theme level you can add a disabled style to every label:
#if LV_USE_LABEL
case LV_THEME_LABEL:
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
_lv_style_list_add_style(list, &styles->label);
break;
#endif
The only problem is that I have a list I use in other part of the code, and sometimes I disable a button of the list, with the line:
lv_btn_set_state(btn, LV_BTN_STATE_DISABLED);
I get the button pointer with:
lv_list_get_next_btn
The fact is that before the label changes, the button appeared as disabled, but now it does not show as disable (though you can not activate it). I don’t know why does that, because if it inheritated the label properties (instead of the ones of the list) it should show the disabled colors of the label.
What seems to have changed is the behaviour of the label inside the button of the list.
Before the change, whenever I disabled the button of the list, the label appeared disabled. But now that label is not shown as disabled.
I don’t know why is doing it, because both the label definition in the list, and the label definition out of the list, have now the LV_STATE_DISABLED color changed.
lv_obj_t *listFindById(lv_obj_t *list, uint8_t id) simply finds a button inside the list, with a Id, which is defined in the ext_attrib when adding the element.
When I set this btn inside the list to disabled, it is disabled (pressing does not affect it), and the text inside the list button appears greyed out.