moly_kit/utils/makepad/
events.rs1use makepad_widgets::{Action, Event, WidgetAction, WidgetActionCast};
2
3pub trait EventExt {
4 fn actions(&self) -> &[Action];
6
7 fn widget_actions(&self) -> impl Iterator<Item = &WidgetAction>;
9}
10
11impl EventExt for Event {
12 fn actions(&self) -> &[Action] {
13 match self {
14 Event::Actions(actions) => actions.as_slice(),
15 _ => &[],
16 }
17 }
18
19 fn widget_actions(&self) -> impl Iterator<Item = &WidgetAction> {
20 self.actions()
21 .iter()
22 .filter_map(|action| action.as_widget_action())
23 }
24}