Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

masonry: fix updating Portal on scrollbar drag #563

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
masonry: when querying widgets by pos, in case of overlap take last
This takes the last child as returned by Widget::children_ids, i.e., the
last in "z-order".
  • Loading branch information
tomcur committed Aug 30, 2024
commit 1cb61eca096ce0c2619b75392144835baddebf52
5 changes: 4 additions & 1 deletion masonry/src/widget/widget_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ impl<'w> WidgetRef<'w, dyn Widget> {

/// Recursively find innermost widget at given position.
///
/// If multiple overlapping children of a widget contain the given position in their layout
/// boxes, the last child as determined by [`Widget::children_ids`] is chosen.
///
/// **pos** - the position in local coordinates (zero being the top-left of the
/// inner widget).
pub fn find_widget_at_pos(&self, pos: Point) -> Option<WidgetRef<'w, dyn Widget>> {
Expand All @@ -190,7 +193,7 @@ impl<'w> WidgetRef<'w, dyn Widget> {
}
}
// TODO - Use Widget::get_child_at_pos method
if let Some(child) = innermost_widget.children().into_iter().find(|child| {
if let Some(child) = innermost_widget.children().into_iter().rev().find(|child| {
!child.widget.skip_pointer() && child.state().window_layout_rect().contains(pos)
}) {
innermost_widget = child;
Expand Down