From ef22786b66a6684404472b41a83dc1493dd4056c Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Tue, 24 Oct 2023 13:55:10 +0200 Subject: [PATCH] fix offset calculations --- ui/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/src/lib.rs b/ui/src/lib.rs index a21b040..ff2125c 100644 --- a/ui/src/lib.rs +++ b/ui/src/lib.rs @@ -177,6 +177,12 @@ pub fn run_event_loop(root_node: SharedNode) -> ! { match path { Some(path) => { + let target_layout = context.node_layout.get(path.last().unwrap()); + let target_layout = match target_layout { + Some(target_layout) => target_layout, + None => { return; } + }; + let target_layout = context.taffy.layout(target_layout.to_owned()).unwrap(); let mevent = MouseEvent { button: Some(button), buttons: mouse_value.buttons, @@ -184,7 +190,7 @@ pub fn run_event_loop(root_node: SharedNode) -> ! { movement: Location::new(0., 0.), device: device_id, modifiers, - offset: Location::new(0., 0.) + offset: location - target_layout.location.into() }; let event = NodeEvent { target: path.last().unwrap().clone(),