Half way done with mouse reporting

This commit is contained in:
Mikayla Maki 2022-08-18 17:37:24 -07:00
parent a0d0c84eee
commit 37ca7a6658
8 changed files with 468 additions and 127 deletions

View file

@ -235,6 +235,7 @@ impl Presenter {
if let Some(root_view_id) = cx.root_view_id(self.window_id) {
let mut invalidated_views = Vec::new();
let mut mouse_down_out_handlers = Vec::new();
let mut mouse_moved_region = None;
let mut mouse_down_region = None;
let mut clicked_region = None;
let mut dragged_region = None;
@ -290,6 +291,15 @@ impl Presenter {
*prev_drag_position = *position;
}
for (region, _) in self.mouse_regions.iter().rev() {
if region.bounds.contains_point(*position) {
invalidated_views.push(region.view_id);
mouse_moved_region =
Some((region.clone(), MouseRegionEvent::Move(e.clone())));
break;
}
}
self.last_mouse_moved_event = Some(event.clone());
}
_ => {}
@ -313,6 +323,17 @@ impl Presenter {
}
}
if let Some((move_moved_region, region_event)) = mouse_moved_region {
handled = true;
if let Some(mouse_moved_callback) =
move_moved_region.handlers.get(&region_event.handler_key())
{
event_cx.with_current_view(move_moved_region.view_id, |event_cx| {
mouse_moved_callback(region_event, event_cx);
})
}
}
if let Some((clicked_region, region_event)) = clicked_region {
handled = true;
if let Some(click_callback) =