Added event on Extension #26
This commit is contained in:
@@ -22,13 +22,9 @@ use crate::{
|
|||||||
|
|
||||||
pub trait Extension {
|
pub trait Extension {
|
||||||
fn init(&mut self, _ctx: &ExtensionContext) {}
|
fn init(&mut self, _ctx: &ExtensionContext) {}
|
||||||
|
fn event(&mut self, _ctx: &ExtensionContext, _event: &dyn Event) {}
|
||||||
fn on_close(&mut self) {}
|
fn on_close(&mut self) {}
|
||||||
fn render_widget(
|
fn render_widget(&mut self, _scope: &mut RenderScope, _widget: &Arc<Widget>) {}
|
||||||
&mut self,
|
|
||||||
_scope: &mut RenderScope,
|
|
||||||
_widget: &Arc<Widget>,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Event: Send + Sync {
|
pub trait Event: Send + Sync {
|
||||||
@@ -84,6 +80,10 @@ impl ExtensionContext {
|
|||||||
for widget in self.screen.widgets.lock().unwrap().iter() {
|
for widget in self.screen.widgets.lock().unwrap().iter() {
|
||||||
widget.event(e);
|
widget.event(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ext in self.screen.extensions.lock().unwrap().iter() {
|
||||||
|
ext.lock().unwrap().event(self, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_widgets(&self) -> MutexGuard<Vec<Arc<Widget>>> {
|
pub fn get_widgets(&self) -> MutexGuard<Vec<Arc<Widget>>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user