1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 14:49:06 -04:00

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.
This commit is contained in:
Andrew Farkas
2026-06-25 13:01:51 -04:00
committed by GitHub
parent 5bf62ca4b3
commit a08630c996
2 changed files with 21 additions and 0 deletions

View File

@@ -1419,6 +1419,9 @@ impl PointerState {
/// Was the given pointer button given clicked this frame? /// 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. /// Returns true on double- and triple- clicks too.
pub fn button_clicked(&self, button: PointerButton) -> bool { pub fn button_clicked(&self, button: PointerButton) -> bool {
self.pointer_events self.pointer_events
@@ -1453,11 +1456,17 @@ impl PointerState {
} }
/// Was the primary button clicked this frame? /// 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 { pub fn primary_clicked(&self) -> bool {
self.button_clicked(PointerButton::Primary) self.button_clicked(PointerButton::Primary)
} }
/// Was the secondary button clicked this frame? /// 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 { pub fn secondary_clicked(&self) -> bool {
self.button_clicked(PointerButton::Secondary) self.button_clicked(PointerButton::Secondary)
} }

View File

@@ -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). /// 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. /// This also returns true if the widget was pressed-and-held on a touch screen.
#[inline] #[inline]
pub fn secondary_clicked(&self) -> bool { 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. /// 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] #[inline]
pub fn middle_clicked(&self) -> bool { pub fn middle_clicked(&self) -> bool {
self.clicked_by(PointerButton::Middle) self.clicked_by(PointerButton::Middle)