Closed justinmoon closed 4 years ago
It seems like lvgl_sys
wants the callback to be an unsafe extern "C"
function, which doesn't really make sense if I'm providing this callback from Rust ...
Hi @justinmoon,
It is flattering that you have interest in using lvgl-rs. I just wanted to tell you that this project is in the very early stages of development. I would really appreciate help of others, like you, to push this project forward. Most things are still missing and I'm still pondering about how to handle the global state dependency in lvgl library rely.
No problem. I'll try to help out wherever I can.
In general, I'm trying to follow the recommendations from those articles:
Thanks for sharing.
I'm trying to figure out how to get these event callbacks working. This post seems to explain roughly what is needed, but still working on it
On a related note, how were you able to get a button to look like this?
Mine look like this
Might help if you could add whatever code produced your screenshot as an example.
@justinmoon that screenshot was in an earlier version of the demo app, https://github.com/rafaelcaricio/lvgl-rs/blob/7bf1ac0cae3b1867b4687efaf1ccbd9e321df54b/examples/demo/src/main.rs I was using SDL directly.
Hey @justinmoon , I just implemented a way to add event callbacks. So you can do things when buttons are clicked, hovered, etc. Please look the example:
let mut button = Button::new(&mut screen);
button.on_event(|this, event| {
if let lvgl::Event::Clicked = event {
println!("Clicked!");
}
});
https://github.com/rafaelcaricio/lvgl-rs/blob/master/examples/bar.rs#L48-L52
I will close this ticket now, as this is now supported. If you have other questions. Please open other issue.
How can I define a button "on-click" callback?
I'm trying to add a button example and I'm stuck trying to type the callback to
lvgl_sys::lvgl_obj_set_event_cb