Lv_obj_add_state vs lv_obj_set_state

Hello all,

I dont know if this has been mentioned before but,

When creating an obj (a panel for example), I am adding a user state by adding styles for this user state other than the default state. Let’s say i change the background colour for this user state, and it is different than the default state.

And if a want to change the background during a case (like a pyhsical button press), i just use the “lv_obj_add_state” function or clear it vice versa.But the naming is confusing i think. this “lv_obj_add_state” function automatically sets the state to the new state. Instead of this, i should be using that function when i initialize the object and when i want to set the state to my user state, i should be using the “lv_obj_set_state” function (which is defined static currently).

This is just a suggestion of course, currently i can do what i need by add state and clear state functions. But still the above makes more sense i think.


The naming is really not the best here. I didn’t use “set” because it would suggest the it sets all states to a value and not just modifying a single bit.

Instead it "add"s a single state to widget.

FYI, in v9 (planned for mid January), it was slightly changed.