diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 2a83f4520..63f06fafa 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1081,7 +1081,6 @@ impl Context { layer_id, id, rect, - interact_rect, sense, enabled, contains_pointer, diff --git a/crates/egui/src/layers.rs b/crates/egui/src/layers.rs index e4dcb913e..4745f1ac7 100644 --- a/crates/egui/src/layers.rs +++ b/crates/egui/src/layers.rs @@ -170,6 +170,10 @@ impl PaintList { pub fn all_entries(&self) -> impl ExactSizeIterator { self.0.iter() } + + pub fn last(&self) -> Option<&ClippedShape> { + self.0.last() + } } /// This is where painted [`Shape`]s end up during a frame. diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index 073ab5615..291ba0d0b 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -32,15 +32,6 @@ pub struct Response { /// The area of the screen we are talking about. pub rect: Rect, - /// The rectangle sensing interaction. - /// - /// This is sometimes smaller than [`Self::rect`] because of clipping - /// (e.g. when inside a scroll area). - /// - /// The interact rect may also be slightly larger than the widget rect, - /// because egui adds half if the item spacing to make the interact rect easier to hit. - pub interact_rect: Rect, - /// The senses (click and/or drag) that the widget was interested in (if any). pub sense: Sense, @@ -610,11 +601,20 @@ impl Response { /// ``` #[must_use] pub fn interact(&self, sense: Sense) -> Self { + // Temporary hack for 0.26.1 to avoid breaking change. + let clip_rect = self.ctx.graphics(|g| { + g.get(self.layer_id) + .and_then(|list| list.last()) + .map(|c| c.clip_rect) + }); + let clip_rect = clip_rect.unwrap_or(Rect::EVERYTHING); + let interact_rect = self.rect.intersect(clip_rect); + self.ctx.interact_with_hovered( self.layer_id, self.id, self.rect, - self.interact_rect, + interact_rect, sense, self.enabled, self.contains_pointer, @@ -809,7 +809,6 @@ impl Response { layer_id: self.layer_id, id: self.id, rect: self.rect.union(other.rect), - interact_rect: self.interact_rect.union(other.interact_rect), sense: self.sense.union(other.sense), enabled: self.enabled || other.enabled, contains_pointer: self.contains_pointer || other.contains_pointer,