pub struct InteractionState { /* private fields */ }Expand description
The tracked interaction state of one piece: whether the pointer is over it, whether it is pressed, and whether it has the keyboard (docs/gestures.md “State styling”).
Create one, attach it with Decorate::interaction, and read it from any reactive
modifier. Each read is tracked, so the modifier follows the state with no handler in between:
let state = InteractionState::new();
row((icon, title))
.interaction(state)
.background(move || if state.pressed() { PRESSED } else if state.hovered() { HOVER } else { REST })
.opacity(move || if state.pressed() { 0.7 } else { 1.0 })hovered follows the pointer where one exists and stays false on a touch-only device.
pressed is true from the pointer-down itself until the release, the pointer leaving, or
the platform taking the gesture away. focused follows keyboard focus on a piece that can
take it (Decorate::focusable, or a control inside). All three read false while the
piece is disabled (Decorate::enabled).
Implementations§
Source§impl InteractionState
impl InteractionState
Sourcepub fn new() -> InteractionState
pub fn new() -> InteractionState
A state with nothing hovered, pressed or focused, owned by the scope it is created in.
Trait Implementations§
Source§impl Clone for InteractionState
impl Clone for InteractionState
Source§fn clone(&self) -> InteractionState
fn clone(&self) -> InteractionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for InteractionState
Source§impl Default for InteractionState
impl Default for InteractionState
Source§fn default() -> InteractionState
fn default() -> InteractionState
Auto Trait Implementations§
impl !Send for InteractionState
impl !Sync for InteractionState
impl Forget for InteractionState
impl Freeze for InteractionState
impl Move for InteractionState
impl RefUnwindSafe for InteractionState
impl Unpin for InteractionState
impl UnsafeUnpin for InteractionState
impl UnwindSafe for InteractionState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more