Added event on Extension #26

This commit is contained in:
2025-08-04 04:50:52 -05:00
parent 48397c06fa
commit 62e0c1eac1
+6 -6
View File
@@ -22,13 +22,9 @@ use crate::{
pub trait Extension {
fn init(&mut self, _ctx: &ExtensionContext) {}
fn event(&mut self, _ctx: &ExtensionContext, _event: &dyn Event) {}
fn on_close(&mut self) {}
fn render_widget(
&mut self,
_scope: &mut RenderScope,
_widget: &Arc<Widget>,
) {
}
fn render_widget(&mut self, _scope: &mut RenderScope, _widget: &Arc<Widget>) {}
}
pub trait Event: Send + Sync {
@@ -84,6 +80,10 @@ impl ExtensionContext {
for widget in self.screen.widgets.lock().unwrap().iter() {
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>>> {