pub struct Pressable {Show 20 fields
pub id: Option<WidgetId>,
pub child: Widget,
pub on_press: Option<ActionEnvelope>,
pub label: Option<String>,
pub semantics_identifier: Option<String>,
pub hyperlink: Option<Hyperlink>,
pub popover_target: Option<PopoverTarget>,
pub role: PressableRole,
pub focus_policy: FocusPolicy,
pub disabled: bool,
pub layout: BoxStyle,
pub flex_grow: f32,
pub flex_shrink: f32,
pub style: PressableStyle,
pub hover_style: Option<PressableStyle>,
pub pressed_style: Option<PressableStyle>,
pub focused_style: Option<PressableStyle>,
pub disabled_style: Option<PressableStyle>,
pub transition: Option<MotionTransition>,
pub ripple: Option<RippleFx>,
}Expand description
A visually neutral accessible interaction surface.
Pressable contributes no visual chrome or geometry unless explicitly
supplied through PressableStyle or BoxStyle. It still provides
semantic activation, focus handling, keyboard activation, pointer state,
optional transitions, and optional ripple feedback.
§Example
Pressable::new(Text::new("Open report"))
.id(WidgetId::explicit("report.open"))
.semantics_identifier("report.open")
.label("Open report")
.role(PressableRole::Button)
.on_press(open_report)
.layout(BoxStyle::default().padding_symmetric(
Length::points(tokens.spacing.m),
Length::points(tokens.spacing.s),
))
.into()Fields§
§id: Option<WidgetId>Optional stable identity used for interaction state, focus, and motion.
child: WidgetChild content rendered inside the interaction surface.
on_press: Option<ActionEnvelope>Action dispatched when the pressable is activated.
label: Option<String>Accessible label exposed to assistive technologies.
semantics_identifier: Option<String>Stable semantic identifier used by tests and accessibility tooling.
hyperlink: Option<Hyperlink>Optional genuine navigation destination.
popover_target: Option<PopoverTarget>Optional standards-based HTML popover invocation.
role: PressableRoleAccessibility role exposed by the semantic node.
focus_policy: FocusPolicyHow pointer activation should affect keyboard focus.
disabled: boolWhether the pressable can receive focus or activation.
layout: BoxStyleTyped layout box model for size, margin, padding, and placement.
flex_grow: f32Legacy point-based flex grow factor.
flex_shrink: f32Legacy point-based flex shrink factor.
style: PressableStyleBase visual state.
hover_style: Option<PressableStyle>Style overlay while hovered.
pressed_style: Option<PressableStyle>Style overlay while actively pressed.
focused_style: Option<PressableStyle>Style overlay while focused.
disabled_style: Option<PressableStyle>Style overlay while disabled.
transition: Option<MotionTransition>Optional transition for state-style changes.
ripple: Option<RippleFx>Optional ripple feedback.
Implementations§
Source§impl Pressable
impl Pressable
Sourcepub fn id(self, id: WidgetId) -> Self
pub fn id(self, id: WidgetId) -> Self
Uses an explicit stable identity for interaction, focus, and motion.
Sourcepub fn on_press(self, action: ActionEnvelope) -> Self
pub fn on_press(self, action: ActionEnvelope) -> Self
Dispatches action for pointer, keyboard, or accessibility activation.
Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Enables or disables activation and focus participation.
Sourcepub fn layout(self, style: BoxStyle) -> Self
pub fn layout(self, style: BoxStyle) -> Self
Applies the shared typed box model without introducing visual defaults.
Sourcepub fn focus_policy(self, policy: FocusPolicy) -> Self
pub fn focus_policy(self, policy: FocusPolicy) -> Self
Selects how pointer activation affects keyboard focus.
Sourcepub fn style(self, style: PressableStyle) -> Self
pub fn style(self, style: PressableStyle) -> Self
Sets the base visual style.
Sourcepub fn hover(self, style: PressableStyle) -> Self
pub fn hover(self, style: PressableStyle) -> Self
Sets the style overlay while the pointer is over the pressable.
Sourcepub fn pressed(self, style: PressableStyle) -> Self
pub fn pressed(self, style: PressableStyle) -> Self
Sets the style overlay while the pressable is active.
Sourcepub fn focused(self, style: PressableStyle) -> Self
pub fn focused(self, style: PressableStyle) -> Self
Sets the style overlay while the pressable owns keyboard focus.
Sourcepub fn disabled_style(self, style: PressableStyle) -> Self
pub fn disabled_style(self, style: PressableStyle) -> Self
Sets the style overlay while activation is disabled.
Sourcepub fn transition(self, transition: MotionTransition) -> Self
pub fn transition(self, transition: MotionTransition) -> Self
Animates supported properties between interaction states.
Sourcepub fn semantics_identifier(self, identifier: impl Into<String>) -> Self
pub fn semantics_identifier(self, identifier: impl Into<String>) -> Self
Sets a stable semantic identifier for tests and accessibility tools.
Sourcepub fn role(self, role: PressableRole) -> Self
pub fn role(self, role: PressableRole) -> Self
Sets button, link, or menu-item semantics.
pub fn hyperlink(self, hyperlink: Hyperlink) -> Self
pub fn popover_target( self, id: impl Into<String>, action: PopoverAction, ) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Pressable
impl<'de> Deserialize<'de> for Pressable
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl !RefUnwindSafe for Pressable
impl !UnwindSafe for Pressable
impl Freeze for Pressable
impl Send for Pressable
impl Sync for Pressable
impl Unpin for Pressable
impl UnsafeUnpin for Pressable
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.