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
impl Response
Sourcepub const fn hovered(&self) -> bool
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.
Sourcepub const fn pressed(&self) -> bool
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.
Sourcepub const fn released(&self) -> bool
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).
Sourcepub const fn clicked(&self) -> bool
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.
Sourcepub const fn held(&self) -> bool
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.
Sourcepub const fn dragging(&self) -> bool
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.
Sourcepub const fn focused(&self) -> bool
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.
Sourcepub const fn secondary_clicked(&self) -> bool
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”.
Sourcepub const fn scroll_delta(&self) -> i32
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.