diff --git a/egui/src/containers/area.rs b/egui/src/containers/area.rs index 99d10fbf..b4c9f037 100644 --- a/egui/src/containers/area.rs +++ b/egui/src/containers/area.rs @@ -179,6 +179,7 @@ impl Prepared { let move_response = ctx.interact( layer_id, Rect::everything(), + ctx.style().spacing.item_spacing, state.rect(), interact_id, Sense::click_and_drag(), diff --git a/egui/src/context.rs b/egui/src/context.rs index 470e3677..fca49aba 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -427,11 +427,12 @@ impl Context { self: &Arc, layer_id: LayerId, clip_rect: Rect, + item_spacing: Vec2, rect: Rect, id: Option, sense: Sense, ) -> Response { - let interact_rect = rect.expand2(0.5 * self.style().spacing.item_spacing); // make it easier to click. TODO: nice way to do this + let interact_rect = rect.expand2((0.5 * item_spacing).min(Vec2::splat(5.0))); // make it easier to click let hovered = self.contains_mouse(layer_id, clip_rect, interact_rect); let has_kb_focus = id.map(|id| self.memory().has_kb_focus(id)).unwrap_or(false); diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 38902e14..ac33006c 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -372,14 +372,21 @@ impl Ui { /// # Interaction impl Ui { pub fn interact(&self, rect: Rect, id: Id, sense: Sense) -> Response { - self.ctx() - .interact(self.layer_id(), self.clip_rect(), rect, Some(id), sense) + self.ctx().interact( + self.layer_id(), + self.clip_rect(), + self.style().spacing.item_spacing, + rect, + Some(id), + sense, + ) } pub fn interact_hover(&self, rect: Rect) -> Response { self.ctx().interact( self.layer_id(), self.clip_rect(), + self.style().spacing.item_spacing, rect, None, Sense::nothing(),