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 a handful of 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.
DISABLED is the exception: it’s a modifier over an
existing sense, not a capability of its own.
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 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 DISABLED: Self
pub const DISABLED: Self
Keeps this call’s hit-testing (so Response::hovered
still works, most of the value of showing a disabled control at
all) but suppresses everything else this sense would otherwise
register or report: no FocusRing registration,
and Response::pressed,
released, clicked,
held, dragging,
focused, and
secondary_clicked all report
false, even if the gesture would otherwise satisfy them.
SCROLL is suppressed too: a disabled row’s own
Sense::SCROLL never fires, though this doesn’t stop an enclosing
scrollable list (a separate widget) from scrolling past it.
A modifier, not a capability of its own: combine it with an existing
sense rather than using it alone, e.g. Sense::click() | Sense::DISABLED. See disabled_if for the
common call-site shape.
Sourcepub const NONE: Self
pub const NONE: Self
Senses nothing: interact still
registers the id nowhere and every Response field reports as if
nothing happened, matching Response::default, with one exception:
rect always echoes back the area passed to interact, useful
for purely decorative widgets that still want layout echo.
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 disabled_if(self, disabled: bool) -> Self
pub const fn disabled_if(self, disabled: bool) -> Self
self with DISABLED set if disabled is
true, unchanged otherwise: the common call-site shape,
Sense::click().disabled_if(!save_available), replacing what would
otherwise be a branch between two Sense literals.
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 is_disabled(self) -> bool
pub const fn is_disabled(self) -> bool
true if DISABLED is set.
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