summaryrefslogtreecommitdiffstats
path: root/runtime/src
diff options
context:
space:
mode:
authorLibravatar Cory Forsstrom <cforsstrom18@gmail.com>2023-02-18 13:53:22 -0800
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-14 09:35:06 +0200
commit1ce047cdb3bb210a8a949794d3db88b3a029df81 (patch)
treed67118f52ed3e035565b8ba6af84983229adad74 /runtime/src
parentf44d4292838f0eaa3fca3ce074977082bb2a6be9 (diff)
downloadiced-1ce047cdb3bb210a8a949794d3db88b3a029df81.tar.gz
iced-1ce047cdb3bb210a8a949794d3db88b3a029df81.tar.bz2
iced-1ce047cdb3bb210a8a949794d3db88b3a029df81.zip
Prioritize mouse interaction of deepest `Overlay`
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/user_interface/overlay.rs30
1 files changed, 21 insertions, 9 deletions
diff --git a/runtime/src/user_interface/overlay.rs b/runtime/src/user_interface/overlay.rs
index 590cc49f..f80d1914 100644
--- a/runtime/src/user_interface/overlay.rs
+++ b/runtime/src/user_interface/overlay.rs
@@ -224,16 +224,28 @@ where
{
let layout = layouts.next().unwrap();
- let interaction =
- if let Some(mut overlay) = element.overlay(layout, renderer) {
- recurse(&mut overlay, layouts, cursor, viewport, renderer)
- } else {
- mouse::Interaction::default()
- };
+ if let Some(cursor_position) = cursor.position() {
+ match element.overlay(layout, renderer) {
+ Some(mut overlay)
+ if overlay.is_over(
+ layout,
+ renderer,
+ cursor_position,
+ ) =>
+ {
+ return recurse(
+ &mut overlay,
+ layouts,
+ cursor,
+ viewport,
+ renderer,
+ );
+ }
+ _ => {}
+ }
+ }
- element
- .mouse_interaction(layout, cursor, viewport, renderer)
- .max(interaction)
+ element.mouse_interaction(layout, cursor, viewport, renderer)
}
self.overlay.with_element_mut(|element| {