I wanna ask about the function lv_obj_add/clear_state , which effect on events they have? I give an example to explain what i want to understand :
two checkable buttons, both have their events the way in code snippet bellow,
the events created bellow will be trigerred just in case i press on button to change state and the function lv_obj_clear_state doesn’t trigger the event LV_EVENT_VALUE_CHANGED of the second one, is this normal ?
In docs nothing is talking about events triggered in changing states, events are triggered when states are automatically changed by the library but it doesn’t work when we do it manually, is it developped this way ? if it’s the case do you suggest to add lv_event_send to the object concerned ?
What MCU/Processor/Board and compiler are you using?
eclipse simulator (windows)
What LVGL version are you using?
8.3.3
What do you want to achieve?
trigger events by changing state of object by another one manually
Obviously, buttons should be checkable otherwise it won’t work,
for the example i gave events are triggered when i press a button,
press the button1 to be checked ==event_button1_cb==> unchecking button2 by lv_obj_clear_state(button2,LV_STATE_CHECKED); when this happens it should trigger event_button2_cb because the value is changing checked to default
so changing state of an object should trigger the event LV_EVENT_VALUE_CHANGED, and i want to understand, if we change state manually is it going to trigger events automatically by Library? or i should add after all conditions lv_event_send(button2,LV_EVENT_VALUE_CHANGED,NULL);
(as i did in example i sent to you by email, I used LV_EVENT_REFRESH, I’m waiting for your feedback when you have time)
Here I just find out that changing state manually (of a checkable object) doesn’t trigger LV_EVENT_VALUE_CHANGED, and it’s triggered just in case of we pressed on it (here events works correctly by library) , I wondered if it’s not a bug or it was designed to work like that
I think we should ask @kisvegabor to confirm whether this is expected behaviour, the library code suggests it probably is working as intended and you probably should send the event yourself, but I could be wrong
Hopefully I will get around to looking at your earlier request properly this week , I have been working away for a couple of weeks and I am still catching up after returning to my office. Thank you for your patience…
That’s what i think too, i just get confused that i change state manually so it doesn’t trigger the event LV_EVENT_VALUE_CHANGED as it does in press of button, maybe it’s intended to another event, for that i asked for the effect of changing state manually.
Don’t worry about it, Thank you for your help, i appreciate
I see that lv_obj_add/clear_state doesn’t send event because it’s a basic function used in library before handling event and it helps to handle events by library, so as I see i should send event manually too in case of using this function,
For now it’s working for check and uncheck, i didn’t tested it for focused or disabled as i don’t know if the LV_EVENT VALUE_CHANGED in other states or not
waiting for @kisvegabor’s answer concerning this subject, and if the event which is used for the change of state is indeed LV_EVENT_VALUE_CHANGED,
It’s the intended behavior, i.e. to not send events on manual changes. E.g. lv_slider_set_value() won’t send VALUE_CHANGED event either.
I was thinking a lot about it and in the earlier days of LVGL and I have tried both. In the end I kept with the no event version mainly because it’s more flexible. If the events were included you couldn’t prevent firing them. However you always have the opportunity to send the events manually.