Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/views/drag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ pub struct DragFunc<F> {
pub f: F,
}

impl<A: 'static, F: Fn(&mut Context, LocalOffset, GestureState, Option<MouseButton>) -> A + Clone> DragFn
for DragFunc<F>
impl<
A: 'static,
F: Fn(&mut Context, LocalOffset, GestureState, Option<MouseButton>) -> A + Clone,
> DragFn for DragFunc<F>
{
fn call(
&self,
Expand All @@ -47,8 +49,10 @@ pub struct DragFuncP<F> {
pub f: F,
}

impl<A: 'static, F: Fn(&mut Context, LocalPoint, GestureState, Option<MouseButton>) -> A + Clone> DragFn
for DragFuncP<F>
impl<
A: 'static,
F: Fn(&mut Context, LocalPoint, GestureState, Option<MouseButton>) -> A + Clone,
> DragFn for DragFuncP<F>
{
fn call(
&self,
Expand Down Expand Up @@ -183,7 +187,11 @@ where
);
}
}
_ => (),
_ => {
path.push(0);
self.child.process(event, path, cx, actions);
path.pop();
}
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/views/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,27 @@ where
fn process(
&self,
event: &Event,
_path: &mut IdPath,
path: &mut IdPath,
cx: &mut Context,
actions: &mut Vec<Box<dyn Any>>,
) {
match self.kind {
KeyViewKind::Pressed => {
if let Event::Key(key) = &event {
actions.push(Box::new((self.func)(cx, key.clone())));
actions.push(Box::new((self.func)(cx, *key)));
} else {
path.push(0);
self.child.process(event, path, cx, actions);
path.pop();
}
}
KeyViewKind::Released => {
if let Event::KeyReleased(key) = &event {
actions.push(Box::new((self.func)(cx, key.clone())));
actions.push(Box::new((self.func)(cx, *key)));
} else {
path.push(0);
self.child.process(event, path, cx, actions);
path.pop();
}
}
}
Expand Down