diff --git a/crates/ui-contract/src/runtime/pointer.rs b/crates/ui-contract/src/runtime/pointer.rs index 89473d2430..39cd318103 100644 --- a/crates/ui-contract/src/runtime/pointer.rs +++ b/crates/ui-contract/src/runtime/pointer.rs @@ -918,7 +918,7 @@ pub(crate) fn over_part(ctx: &Context, viewport: ViewportId, root: Id, part: Par OverPart { widgets, above } } -/// The bounds, in screen points and clipped to where each shows, of the press-taking shapes of the root whose egui widgets include `widget` in the +/// The hit areas, in screen points and clipped to where each shows, of the press-taking shapes of the root whose egui widgets include `widget` in the /// running pass: where a press over that widget goes to the root's parts (8.3). `None` when no root recorded it, so it /// is a plain egui widget that takes a press anywhere in its rect. pub(crate) fn press_shapes_of_widget(ctx: &Context, viewport: ViewportId, widget: Id) -> Option> { @@ -926,13 +926,18 @@ pub(crate) fn press_shapes_of_widget(ctx: &Context, viewport: ViewportId, widget let mut found = None::)>>; for (layer, roots) in &record.this { for entry in roots.values().filter(|entry| entry.widgets.contains(&widget)) { - // A press reaches a shape only where it shows through its clip (`find_under`). + // A press reaches a shape across its hit area, grown to its least size across (`Shape::hits`), and only + // where it shows through its clip (`find_under`). let bounds = entry .shapes .iter() .zip(&entry.placed) .filter(|(shape, _)| shape.sense.takes_press()) - .map(|(shape, placed)| shape.shape.bounds().intersect(placed.clip)) + .map(|(shape, placed)| { + let bounds = shape.shape.bounds(); + let grow = (egui::Vec2::splat(shape.min_across) - bounds.size()).max(egui::Vec2::ZERO) / 2.0; + bounds.expand2(grow).intersect(placed.clip) + }) .filter(|rect| rect.is_positive()) .collect(); found.get_or_insert_with(Vec::new).push((*layer, bounds));