Skip to main content

Sense

Struct Sense 

Source
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

Source

pub const HOVER: Self

Register the widget’s rect for hit-testing and report Response::hovered.

Source

pub const CLICK: Self

Source

pub const DRAG: Self

Report Response::dragging once the pointer moves past the drag threshold while pressed on this widget.

Source

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.

Source

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.

Source

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.

Source

pub const NONE: Self

Senses nothing: interact still registers the id nowhere and returns Response::default.

Source

pub const fn click() -> Self

A clickable, hoverable, focusable widget: buttons, tabs, list rows. Equivalent to HOVER | CLICK | FOCUSABLE.

Source

pub const fn drag() -> Self

A draggable widget, e.g. a slider or scrollbar thumb. Equivalent to click | DRAG.

Source

pub const fn hover() -> Self

A hover-only widget with no click or focus behavior, e.g. a tooltip trigger. Equivalent to HOVER.

Source

pub const fn scroll() -> Self

A scrollable region, e.g. a list or log panel. Equivalent to HOVER | SCROLL.

Source

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.

Source

pub const fn contains(self, other: Self) -> bool

true if every bit set in other is also set in self.

Source

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 BitOr for Sense

Source§

type Output = Sense

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
Source§

impl BitOrAssign for Sense

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl Clone for Sense

Source§

fn clone(&self) -> Sense

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 Sense

Source§

impl Debug for Sense

Source§

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

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

impl Default for Sense

Source§

fn default() -> Sense

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

impl Eq for Sense

Source§

impl Hash for Sense

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Sense

Source§

fn eq(&self, other: &Sense) -> 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 Sense

Auto Trait Implementations§

§

impl Freeze for Sense

§

impl RefUnwindSafe for Sense

§

impl Send for Sense

§

impl Sync for Sense

§

impl Unpin for Sense

§

impl UnsafeUnpin for Sense

§

impl UnwindSafe for Sense

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).