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:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user