mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-10 21:50:42 +08:00
lib: Pass event to event callback
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ use ratatui::widgets::Cell;
|
||||
pub type BoxedWidget<S, M> = Box<dyn Widget<State = S, Message = M>>;
|
||||
|
||||
pub type UpdateCallback<S> = fn(&S) -> Box<dyn Any>;
|
||||
pub type EventCallback = fn(&mut dyn Any);
|
||||
pub type EventCallback = fn(&mut dyn Any, Key);
|
||||
|
||||
/// A `WidgetBase` provides common functionality to a `Widget`. It's used to store
|
||||
/// event and update callbacks as well sending messages to the UI's message channel.
|
||||
|
||||
@@ -554,7 +554,7 @@ where
|
||||
}
|
||||
|
||||
if let Some(on_event) = self.base.on_event {
|
||||
(on_event)(self);
|
||||
(on_event)(self, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ where
|
||||
}
|
||||
|
||||
if let Some(on_event) = self.base.on_event {
|
||||
(on_event)(self);
|
||||
(on_event)(self, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ where
|
||||
}
|
||||
|
||||
if let Some(on_event) = self.base.on_event {
|
||||
(on_event)(self);
|
||||
(on_event)(self, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ where
|
||||
}
|
||||
|
||||
if let Some(on_event) = self.base.on_event {
|
||||
(on_event)(self);
|
||||
(on_event)(self, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ where
|
||||
impl<'a, S, M, Id> Widget for Window<S, M, Id>
|
||||
where
|
||||
'a: 'static,
|
||||
S: 'static,
|
||||
M: 'static,
|
||||
Id: Clone + Hash + Eq + PartialEq + 'static,
|
||||
{
|
||||
type Message = M;
|
||||
@@ -83,6 +85,10 @@ where
|
||||
if let Some(page) = page {
|
||||
page.handle_event(key);
|
||||
}
|
||||
|
||||
if let Some(on_event) = self.base.on_event {
|
||||
(on_event)(self, key);
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, state: &S) {
|
||||
|
||||
Reference in New Issue
Block a user