Skip to main content

Response

Struct Response 

Source
pub struct Response { /* private fields */ }
Expand description

What happened to a widget this frame, as reported by Interaction::interact.

Every field is scoped to this frame only (e.g. clicked is true for exactly the one frame the release lands on), except focused, which stays true across frames until focus moves elsewhere. Fields a widget didn’t ask for via Sense are always false/0: a widget sensed with only Sense::HOVER never reports clicked, for instance.

Implementations§

Source§

impl Response

Source

pub const fn hovered(&self) -> bool

The pointer is over this widget’s rect, resolved from last frame’s hit-test: see Interaction for why there’s a frame of latency.

Source

pub const fn pressed(&self) -> bool

The primary pointer button went down on this widget this frame, or (sensed with Sense::FOCUSABLE) Enter or Space was pressed while it was focused.

Source

pub const fn released(&self) -> bool

The primary pointer button (or an activating key) was released this frame while this widget was the active one. Fires whether or not the release also counts as a clicked (e.g. it doesn’t, if the gesture crossed the drag threshold first).

Source

pub const fn clicked(&self) -> bool

A full press-release cycle landed on this widget this frame: pressed and released while still hovered, never crossing the drag threshold. Also fires from keyboard activation (Enter/Space while focused) – terminals are frequently mouse-less, so Sense::click widgets are keyboard-operable by default.

Source

pub const fn held(&self) -> bool

The primary pointer button is down and the pointer is currently over this widget’s rect, re-checked live every frame, unlike pressed, which fires once on the down edge and never re-checks position. Automatically cancels (goes false) the instant the pointer slides off this widget’s rect, even before release, without waiting for a release event: the same “slide-to-cancel” feedback is_pointer_button_down_on gives egui widgets and IsItemHovered() && IsItemActive() gives Dear ImGui widgets. Only ever true for widgets sensed with Sense::CLICK.

Source

pub const fn dragging(&self) -> bool

The pointer moved past the drag threshold while pressed on this widget. Only ever true for widgets sensed with Sense::DRAG.

Source

pub const fn focused(&self) -> bool

This widget holds keyboard focus. Unlike the other fields, this is level state, not a one-shot “this happened” flag: it stays true across frames until focus moves to another widget or is cleared.

Source

pub const fn secondary_clicked(&self) -> bool

The secondary (right) mouse button pressed and released on this widget this frame while still hovered. Only ever true for widgets sensed with Sense::SECONDARY_CLICK. Unlike clicked, there’s no keyboard equivalent – a secondary action needs its own trigger (a modifier+Enter, a menu key, whatever fits the app) since Enter/Space already means “primary activate”.

Source

pub const fn scroll_delta(&self) -> i32

Scroll wheel delta accumulated this frame while the pointer was within this widget’s rect (regardless of what else was drawn on top of it; see Sense::SCROLL): positive scrolls forward/down, negative scrolls backward/up. Feeds straight into ListState::scroll_by. Zero unless sensed with SCROLL and something scrolled.

Trait Implementations§

Source§

impl Clone for Response

Source§

fn clone(&self) -> Response

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Response

Source§

impl Debug for Response

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Response

Source§

fn default() -> Response

Returns the “default value” for a type. Read more
Source§

impl Eq for Response

Source§

impl PartialEq for Response

Source§

fn eq(&self, other: &Response) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Response

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<C> WithAlpha for C
where C: Copy,

Source§

fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>

Wraps self with alpha, storing alpha before the color in memory (see AlphaFirst).
Source§

fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>

Wraps self with alpha, storing alpha after the color in memory (see AlphaLast).