From d97282cd9208a2574c3566a965f34a277beb7b44 Mon Sep 17 00:00:00 2001 From: Mason Feurer Date: Sun, 30 Oct 2022 14:59:19 -0500 Subject: [PATCH] Interact with non-Rect shapes (#2199) * added Ui::interact_with_hovered * fixed typo --- crates/egui/src/ui.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 20ffdd3d..d8981ec3 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -618,6 +618,22 @@ impl Ui { ) } + /// Check for clicks, and drags on a specific region that is hovered. + /// This can be used once you have checked that some shape you are painting has been hovered, + /// and want to check for clicks and drags on hovered items this frame. + /// The given [`Rect`] should approximately be where the thing is, + /// as it is just where warnings will be painted if there is an [`Id`] clash. + pub fn interact_with_hovered( + &self, + rect: Rect, + hovered: bool, + id: Id, + sense: Sense, + ) -> Response { + self.ctx() + .interact_with_hovered(self.layer_id(), id, rect, sense, self.enabled, hovered) + } + /// Is the pointer (mouse/touch) above this rectangle in this [`Ui`]? /// /// The `clip_rect` and layer of this [`Ui`] will be respected, so, for instance,