This crate provides a Listener widget which can basically wrap any fltk-rs widget (implementing WidgetBase and WidgetExt) and provides an on_<event>
interface.
toml
fltk = "1.2"
fltk-evented = "0.1"
```rust use fltk::{prelude::*, enums::Color, *}; use fltk_evented::Listener;
fn main() { let app = app::App::default().withscheme(app::Scheme::Gtk); let mut wind = window::Window::default().withsize(400, 300); wind.setcolor(Color::White); let mut but: Listener<_> = button::Button::new(160, 210, 80, 40, "Click me!").into(); but.setcolor(Color::Cyan); but.setselectioncolor(Color::Cyan.darker()); but.clearvisiblefocus(); wind.end(); wind.show();
but.on_hover(|b| {
b.set_color(Color::Cyan.lighter().lighter());
});
but.on_leave(|b| {
b.set_color(Color::Cyan);
});
but.on_click(|_| {
println!("Clicked");
});
app.run().unwrap();
} ```