diff options
Diffstat (limited to 'native/src/overlay')
-rw-r--r-- | native/src/overlay/element.rs | 17 | ||||
-rw-r--r-- | native/src/overlay/group.rs | 13 |
2 files changed, 30 insertions, 0 deletions
diff --git a/native/src/overlay/element.rs b/native/src/overlay/element.rs index 41a8a597..125258c5 100644 --- a/native/src/overlay/element.rs +++ b/native/src/overlay/element.rs @@ -115,6 +115,15 @@ where ) { self.overlay.operate(layout, renderer, operation); } + + /// Whether the [`Overlay`] contains the cursor + pub fn contains_cursor( + &self, + layout: Layout<'_>, + cursor_position: Point, + ) -> bool { + self.overlay.contains_cursor(layout, cursor_position) + } } struct Map<'a, A, B, Renderer> { @@ -252,4 +261,12 @@ where self.content .draw(renderer, theme, style, layout, cursor_position) } + + fn contains_cursor( + &self, + layout: Layout<'_>, + cursor_position: Point, + ) -> bool { + self.content.contains_cursor(layout, cursor_position) + } } diff --git a/native/src/overlay/group.rs b/native/src/overlay/group.rs index f894f911..96d10c19 100644 --- a/native/src/overlay/group.rs +++ b/native/src/overlay/group.rs @@ -151,6 +151,19 @@ where ) }); } + + fn contains_cursor( + &self, + layout: Layout<'_>, + cursor_position: Point, + ) -> bool { + self.children + .iter() + .zip(layout.children()) + .any(|(child, layout)| { + child.contains_cursor(layout, cursor_position) + }) + } } impl<'a, Message, Renderer> From<Group<'a, Message, Renderer>> |