I'm using ftlk UI library to show window and bind some actins on it. But this question isn't ftlk specific.
What would be the right way of triggering actions on other structs from the UI Window?
Example code below
let mut window: DoubleWindow = Window::default().with_label("").with_size(100, 100).center_screen();
window.handle(move |_, event| {
match event {
Event::Released => {
let left = event_button() == 1;
if left {
let (x, y) = event_coords();
struct_with_action.do_actions(x as usize, y as usize);
}
true
}
_ => false,
}
});
A bad solution could be to pass mutable static lifetime reference to struct_with_action and trigger action directly on struct_with_action, but that already brings up too much complications.
What would be the right way to fire event from window handler -> to trigger action somewhere else?
Is there any recommended library or simple implementation to add an event to event queue and register event listener?