Skip to content

Commit

Permalink
Only remember widgets that are visible (inside a clip rect)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Feb 1, 2024
1 parent 6af49f9 commit 97221a4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,8 @@ impl Context {
///
/// Will return false if some other area is covering the given layer.
///
/// The given rectangle is assumed to have been clipped by its parent clip rect.
///
/// See also [`Response::contains_pointer`].
pub fn rect_contains_pointer(&self, layer_id: LayerId, rect: Rect) -> bool {
if !rect.is_positive() {
Expand Down Expand Up @@ -2169,6 +2171,8 @@ impl Context {
/// If another widget is covering us and is listening for the same input (click and/or drag),
/// this will return false.
///
/// The given rectangle is assumed to have been clipped by its parent clip rect.
///
/// See also [`Response::contains_pointer`].
pub fn widget_contains_pointer(
&self,
Expand All @@ -2177,6 +2181,10 @@ impl Context {
sense: Sense,
rect: Rect,
) -> bool {
if !rect.is_positive() {
return false; // don't even remember this widget
}

let contains_pointer = self.rect_contains_pointer(layer_id, rect);

let mut blocking_widget = None;
Expand Down

0 comments on commit 97221a4

Please sign in to comment.