pub struct Sense(/* private fields */);Expand description
Which of a Response’s fields
Interaction::interact should actually
populate for a given widget call.
A manual bitflag over u8: mirrors
KeyModifiers’s shape rather than
pulling in the bitflags crate for five bits. Combine raw flags with
| (Sense::HOVER | Sense::FOCUSABLE), or reach for one of the named
constructors (click, drag,
hover, scroll) for the common cases.
Implementations§
Source§impl Sense
impl Sense
Sourcepub const HOVER: Self
pub const HOVER: Self
Register the widget’s rect for hit-testing and report
Response::hovered.
Sourcepub const CLICK: Self
pub const CLICK: Self
Report Response::pressed,
Response::released, and
Response::clicked.
Sourcepub const DRAG: Self
pub const DRAG: Self
Report Response::dragging once the
pointer moves past the drag threshold while pressed on this widget.
Sourcepub const FOCUSABLE: Self
pub const FOCUSABLE: Self
Register the widget in the FocusRing’s
Tab/Shift+Tab order and report
Response::focused. Combined with
CLICK, Enter/Space also activate the widget while
it’s focused: terminals are frequently mouse-less.
Sourcepub const SCROLL: Self
pub const SCROLL: Self
Report Response::scroll_delta
whenever the pointer is within this widget’s rect. Unlike the other
pointer senses, this is deliberately not limited to the single
topmost widget under the pointer: see Interaction::interact’s
doc comment on scroll_delta for why.
Sourcepub const SECONDARY_CLICK: Self
pub const SECONDARY_CLICK: Self
Report Response::secondary_clicked:
the secondary (right) button pressed and released on this widget
while still hovered. Independent of CLICK: combine
them (Sense::click() | Sense::SECONDARY_CLICK) for a widget that
wants both a primary action and a secondary one (e.g. a context
menu). Unlike CLICK/DRAG, there’s no
drag-threshold suppression for the secondary button: a
press-and-release on the same widget always counts, since
secondary-button drags aren’t a gesture this module resolves.
Sourcepub const NONE: Self
pub const NONE: Self
Senses nothing: interact still
registers the id nowhere and returns Response::default.
Sourcepub const fn click() -> Self
pub const fn click() -> Self
A clickable, hoverable, focusable widget: buttons, tabs, list
rows. Equivalent to HOVER | CLICK | FOCUSABLE.
Sourcepub const fn drag() -> Self
pub const fn drag() -> Self
A draggable widget, e.g. a slider or scrollbar thumb. Equivalent to
click | DRAG.
Sourcepub const fn hover() -> Self
pub const fn hover() -> Self
A hover-only widget with no click or focus behavior, e.g. a tooltip
trigger. Equivalent to HOVER.
Sourcepub const fn scroll() -> Self
pub const fn scroll() -> Self
A scrollable region, e.g. a list or log panel. Equivalent to
HOVER | SCROLL.
Sourcepub const fn secondary_click() -> Self
pub const fn secondary_click() -> Self
A widget with a secondary (right-click) action but no primary click,
e.g. a context-menu-only trigger. Equivalent to HOVER | SECONDARY_CLICK.
Combine with click (Sense::click() | Sense::SECONDARY_CLICK)
for a widget with both a primary and a secondary action.
Sourcepub const fn contains(self, other: Self) -> bool
pub const fn contains(self, other: Self) -> bool
true if every bit set in other is also set in self.
Sourcepub const fn wants_pointer(self) -> bool
pub const fn wants_pointer(self) -> bool
true if this sense wants pointer hit-testing at all (HOVER,
CLICK, DRAG, SCROLL,
or SECONDARY_CLICK).
Trait Implementations§
Source§impl BitOrAssign for Sense
impl BitOrAssign for Sense
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read more