Skip to main content

MouseClickingStrategy

Enum MouseClickingStrategy 

Source
pub enum MouseClickingStrategy {
    Pressed,
    NotPressed,
    FallingEdge,
    RisingEdge,
    DoubleEdge {
        rising_edge: bool,
    },
    RisingHold {
        rising_edge: bool,
        time: f32,
        goal: f32,
    },
    Hold {
        time: f32,
        goal: f32,
    },
}
Expand description

Determines when MouseButtonManager::is_clicked returns true.

Each variant tracks button state through an internal edge detector. All variants respect the manager’s cooldown: while cooldown > 0, is_clicked() always returns false and button presses are ignored.

After handling a click, call MouseButtonManager::change_cooldown to set a debounce duration; the cooldown does not restart automatically.

§Variants

Variantis_clicked when
PressedButton is gated-pressed this frame
NotPressedButton is not gated-pressed
FallingEdgeFalling edge of gated press (release)
RisingEdgeRising edge of gated press (initial press)
DoubleEdgeRelease after a valid press-while-hovered sequence
RisingHoldHold timer reaches goal while armed
HoldHold timer reaches goal while pressed and hovered

Variants§

§

Pressed

is_clicked is true while the button is held (after cooldown).

§

NotPressed

is_clicked is true while the button is not held (after cooldown).

§

FallingEdge

is_clicked is true on the frame the button is released.

§

RisingEdge

is_clicked is true on the frame the button is first pressed.

§

DoubleEdge

Click-on-release after a press-while-hovered sequence.

During a press, rising_edge is armed when hovered and cooldown has expired. is_clicked fires on the release (falling edge) when armed.

§Note

This is not an operating-system double-click detector.

Fields

§rising_edge: bool

Internal arming flag; initialized to false.

§

RisingHold

Fires when time >= goal after the same arming logic as DoubleEdge.

While armed, time increases each frame; when not armed, time decreases. time resets to zero when the button is released.

Fields

§rising_edge: bool

Internal arming flag; initialized to false.

§time: f32

Accumulated hold time in seconds.

§goal: f32

Duration in seconds required for is_clicked to return true.

§

Hold

Fires when time >= goal while the button is held and the element is hovered.

time resets to zero when the button is released or the cursor leaves the hover region.

Fields

§time: f32

Accumulated hold time in seconds.

§goal: f32

Duration in seconds required for is_clicked to return true.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.