From a08630c99649e52ae570acdb48c287bddefacbfe Mon Sep 17 00:00:00 2001 From: Andrew Farkas <6060305+HactarCE@users.noreply.github.com> Date: Thu, 25 Jun 2026 13:01:51 -0400 Subject: [PATCH] Improve docs on some methods to clarify what counts as a "click" (#8251) * [x] I have followed the instructions in the PR template Just a small docs change, since I saw this trip someone up. The ones on `Response` may be redundant. --- crates/egui/src/input_state/mod.rs | 9 +++++++++ crates/egui/src/response.rs | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/crates/egui/src/input_state/mod.rs b/crates/egui/src/input_state/mod.rs index dc07ffeb7..55c76bb06 100644 --- a/crates/egui/src/input_state/mod.rs +++ b/crates/egui/src/input_state/mod.rs @@ -1419,6 +1419,9 @@ impl PointerState { /// Was the given pointer button given clicked this frame? /// + /// A click is registered when the mouse or touch is released within + /// a certain amount of time and distance from when and where it was pressed. + /// /// Returns true on double- and triple- clicks too. pub fn button_clicked(&self, button: PointerButton) -> bool { self.pointer_events @@ -1453,11 +1456,17 @@ impl PointerState { } /// Was the primary button clicked this frame? + /// + /// A click is registered when the mouse or touch is released within + /// a certain amount of time and distance from when and where it was pressed. pub fn primary_clicked(&self) -> bool { self.button_clicked(PointerButton::Primary) } /// Was the secondary button clicked this frame? + /// + /// A click is registered when the mouse or touch is released within + /// a certain amount of time and distance from when and where it was pressed. pub fn secondary_clicked(&self) -> bool { self.button_clicked(PointerButton::Secondary) } diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index 54d53f2b4..81d04f1ef 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -199,6 +199,12 @@ impl Response { /// Returns true if this widget was clicked this frame by the secondary mouse button (e.g. the right mouse button). /// + /// A click is registered when the mouse or touch is released within + /// a certain amount of time and distance from when and where it was pressed. + /// + /// Note that the widget must be sensing clicks with [`Sense::click`]. + /// [`crate::Button`] senses clicks; [`crate::Label`] does not (unless you call [`crate::Label::sense`]). + /// /// This also returns true if the widget was pressed-and-held on a touch screen. #[inline] pub fn secondary_clicked(&self) -> bool { @@ -214,6 +220,12 @@ impl Response { } /// Returns true if this widget was clicked this frame by the middle mouse button. + /// + /// A click is registered when the mouse or touch is released within + /// a certain amount of time and distance from when and where it was pressed. + /// + /// Note that the widget must be sensing clicks with [`Sense::click`]. + /// [`crate::Button`] senses clicks; [`crate::Label`] does not (unless you call [`crate::Label::sense`]). #[inline] pub fn middle_clicked(&self) -> bool { self.clicked_by(PointerButton::Middle)