AIT/src/controller/event_handlers/switch_event_handlers.rs

17 lines
418 B
Rust

use crate::{gtk::prelude::*, model::model::*, view::components::switch::SwitchExt};
pub trait SwEventHandler {
fn on_toggle(self) -> ();
}
impl<F, C> SwEventHandler for EventHandler<F, C>
where
F: Fn(&C) + FnOnce(&C) + FnMut(&C) + 'static,
C: SwitchExt + WidgetExt,
{
fn on_toggle(self) -> () {
self.component
.connect_state_notify(move |switch| (self.callback)(switch));
}
}