Fix scroll event passthrough in Stack widget
This commit is contained in:
parent
5d7d74ffa4
commit
889d8b891f
1 changed files with 21 additions and 5 deletions
|
|
@ -209,19 +209,23 @@ where
|
||||||
tree: &mut Tree,
|
tree: &mut Tree,
|
||||||
event: Event,
|
event: Event,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor: mouse::Cursor,
|
mut cursor: mouse::Cursor,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
clipboard: &mut dyn Clipboard,
|
clipboard: &mut dyn Clipboard,
|
||||||
shell: &mut Shell<'_, Message>,
|
shell: &mut Shell<'_, Message>,
|
||||||
viewport: &Rectangle,
|
viewport: &Rectangle,
|
||||||
) -> event::Status {
|
) -> event::Status {
|
||||||
|
let is_over_scroll =
|
||||||
|
matches!(event, Event::Mouse(mouse::Event::WheelScrolled { .. }))
|
||||||
|
&& cursor.is_over(layout.bounds());
|
||||||
|
|
||||||
self.children
|
self.children
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.rev()
|
.rev()
|
||||||
.zip(tree.children.iter_mut().rev())
|
.zip(tree.children.iter_mut().rev())
|
||||||
.zip(layout.children().rev())
|
.zip(layout.children().rev())
|
||||||
.map(|((child, state), layout)| {
|
.map(|((child, state), layout)| {
|
||||||
child.as_widget_mut().on_event(
|
let status = child.as_widget_mut().on_event(
|
||||||
state,
|
state,
|
||||||
event.clone(),
|
event.clone(),
|
||||||
layout,
|
layout,
|
||||||
|
|
@ -230,7 +234,19 @@ where
|
||||||
clipboard,
|
clipboard,
|
||||||
shell,
|
shell,
|
||||||
viewport,
|
viewport,
|
||||||
)
|
);
|
||||||
|
|
||||||
|
if is_over_scroll {
|
||||||
|
let interaction = child.as_widget().mouse_interaction(
|
||||||
|
state, layout, cursor, viewport, renderer,
|
||||||
|
);
|
||||||
|
|
||||||
|
if interaction != mouse::Interaction::None {
|
||||||
|
cursor = mouse::Cursor::Unavailable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status
|
||||||
})
|
})
|
||||||
.find(|&status| status == event::Status::Captured)
|
.find(|&status| status == event::Status::Captured)
|
||||||
.unwrap_or(event::Status::Ignored)
|
.unwrap_or(event::Status::Ignored)
|
||||||
|
|
@ -283,9 +299,9 @@ where
|
||||||
interaction != mouse::Interaction::None
|
interaction != mouse::Interaction::None
|
||||||
})
|
})
|
||||||
.map(|i| self.children.len() - i - 1)
|
.map(|i| self.children.len() - i - 1)
|
||||||
.unwrap_or(self.children.len())
|
.unwrap_or_default()
|
||||||
} else {
|
} else {
|
||||||
self.children.len()
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut layers = self
|
let mut layers = self
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue