From 09f5c7c23e36210ecf17de25a01434f3de17d738 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 26 Apr 2021 15:53:23 -0700 Subject: [PATCH] Fix scrollwheel events in uniformlist Co-Authored-By: Nathan Sobo --- gpui/src/elements/uniform_list.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/gpui/src/elements/uniform_list.rs b/gpui/src/elements/uniform_list.rs index c1b9b86ca729393669247dc549cc50a463e2cd73..161b465ac869a89c07dd3d937e7f8ba628f3eff6 100644 --- a/gpui/src/elements/uniform_list.rs +++ b/gpui/src/elements/uniform_list.rs @@ -74,10 +74,6 @@ where scroll_max: f32, ctx: &mut EventContext, ) -> bool { - if !self.rect().unwrap().contains_point(position) { - return false; - } - if !precise { todo!("still need to handle non-precise scroll events from a mouse wheel"); } @@ -111,11 +107,6 @@ where fn scroll_top(&self) -> f32 { self.state.0.lock().scroll_top } - - fn rect(&self) -> Option { - todo!() - // try_rect(self.origin, self.size) - } } impl Element for UniformList @@ -213,7 +204,7 @@ where fn dispatch_event( &mut self, event: &Event, - _: RectF, + bounds: RectF, layout: &mut Self::LayoutState, _: &mut Self::PaintState, ctx: &mut EventContext, @@ -229,8 +220,10 @@ where delta, precise, } => { - if self.scroll(*position, *delta, *precise, layout.scroll_max, ctx) { - handled = true; + if bounds.contains_point(*position) { + if self.scroll(*position, *delta, *precise, layout.scroll_max, ctx) { + handled = true; + } } } _ => {}