Fully refactored project architecture, imports and etc.
This commit is contained in:
34
src/controller/event_handlers/button_event_handlers.rs
Normal file
34
src/controller/event_handlers/button_event_handlers.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
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)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user