The button state changed when other objects are refreshing,and the new state didn’t show correctly,it’s till in the previous state,but the state has changed as it should be by the set state function.
First of all ,the buttons here are to remind users what are they used for,they are not in a group and bind to input device,I set the state of it manualy when button pressed or released by sending event to its callback function,and set state in its callback.
The routine is like : button_pressed->send button pressing event->change its state to focused(a style aplly to it)->delete some objects and create some on the screen(change screen)->button released->send release event(change its state to default while the screen is still refreshing )->screen changed ok,but the new state of the button not changed on the screen.
If I release the button a little slowly after others’ refreshing done,then the new state will display good.
stm32l476rct6
show the right state of the button when state changed
I trid to refresh it after others’ refreshing done,and it works,the new state will show good
I think that object states can’t be altered mid-refresh without rendering problems like this. However, you should be able to use lv_async_call to schedule the call for the next LVGL “tick”. The delay is likely to be unnoticeable for a human.
Alternatively invalidating the object after changing its state might also work.
monitor_cb is called when rendering finishes, but you wouldn’t want to unconditionally invalidate the buttons in there, or they would get redrawn on every single frame (which is a waste of power and CPU resources). You would need to check whether the state really did change.
I think using an async callback would be much cleaner.
Yeah,that’s a little inconvenient,especially when freshing goes slowly.
The events happened during drawing should be queued for later check,if something changed then refresh it.