34 lines
800 B
Rust
34 lines
800 B
Rust
|
pub mod button_event_handlers_module{
|
||
|
|
||
|
use crate::{
|
||
|
model::model::model_module::*,
|
||
|
gtk::{
|
||
|
*,
|
||
|
prelude::*
|
||
|
},
|
||
|
};
|
||
|
|
||
|
impl<F, C> EventHandler<F, C>
|
||
|
where F: Fn(&C) + FnOnce(&C) + FnMut(&C){
|
||
|
pub fn new(component: C, callback: F) -> EventHandler<F, C>{
|
||
|
Self{
|
||
|
component,
|
||
|
callback,
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub trait BtnEventHandler{
|
||
|
fn on_click(self) -> ();
|
||
|
}
|
||
|
|
||
|
impl<F, C> BtnEventHandler for EventHandler<F, C>
|
||
|
where F: Fn(&C) + FnOnce(&C) + FnMut(&C) + 'static, C: ButtonExt + WidgetExt{
|
||
|
fn on_click(self) -> () {
|
||
|
self.component.connect_clicked(move |button| {
|
||
|
(self.callback)(button)
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|