pub struct Button { /* private fields */ }Expand description
A labeled action.
The click handler is only installed when the button is enabled and not loading, so an unavailable action cannot fire through a stray event.
Implementations§
Source§impl Button
impl Button
pub fn new(ident: impl Into<Ident>) -> Self
pub fn label(self, label: impl Into<SharedString>) -> Self
Sourcepub fn accessible_name(self, name: impl Into<SharedString>) -> Self
pub fn accessible_name(self, name: impl Into<SharedString>) -> Self
What assistive technology and a test call this action.
Overrides the label, which a graphic button does not have.
Sourcepub fn accessible_description(
self,
description: impl Into<SharedString>,
) -> Self
pub fn accessible_description( self, description: impl Into<SharedString>, ) -> Self
Adds supplementary literal help to the native button node.
Sourcepub fn icon_only(self, glyph: Icon, name: impl Into<SharedString>) -> Self
pub fn icon_only(self, glyph: Icon, name: impl Into<SharedString>) -> Self
Draws the button as a square carrying only its glyph, and names it.
The name is required rather than optional because a glyph on its own is an action nobody can announce or address.
Sourcepub fn join(self, join: ButtonJoin) -> Self
pub fn join(self, join: ButtonJoin) -> Self
Places the button in a joined run.
Sourcepub fn semantic_parent(self, parent: impl Into<SharedString>) -> Self
pub fn semantic_parent(self, parent: impl Into<SharedString>) -> Self
Names the surface this action belongs to in the semantic tree, so a reader can tell which notification or row an action came from.
pub fn icon(self, glyph: Icon) -> Self
pub fn icon_position(self, position: IconPosition) -> Self
pub fn variant(self, variant: ButtonVariant) -> Self
pub fn primary(self) -> Self
pub fn secondary(self) -> Self
pub fn ghost(self) -> Self
pub fn danger(self) -> Self
pub fn link(self) -> Self
Sourcepub fn loading(self, loading: bool) -> Self
pub fn loading(self, loading: bool) -> Self
Marks the action as in flight. A loading button is not actionable.
pub fn full_width(self, full_width: bool) -> Self
Sourcepub fn track_focus(self, handle: &FocusHandle) -> Self
pub fn track_focus(self, handle: &FocusHandle) -> Self
Puts the button on a caller-owned focus handle.
An overlay that keeps its own tab order needs a handle it can focus directly, and the published node then reports whether the keyboard is on this action.
pub fn on_click(self, handler: impl Fn(&mut Window, &mut App) + 'static) -> Self
Sourcepub fn checked_state(self, checked: bool) -> Self
pub fn checked_state(self, checked: bool) -> Self
Publishes an explicit two-state answer, for a button that stays in.
A selected button publishes checked only when it is selected, because
“this is the current one” has no meaningful false. A toggle does: out
is a state, not the absence of one, so it says so.
Trait Implementations§
Source§impl IntoElement for Button
impl IntoElement for Button
Source§type Element = ViewElement<Button>
type Element = ViewElement<Button>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Button
impl RenderOnce for Button
Source§fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Button
impl !Send for Button
impl !Sync for Button
impl !UnwindSafe for Button
impl Freeze for Button
impl Unpin for Button
impl UnsafeUnpin for Button
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<E> Flipping for Ewhere
E: IntoElement,
impl<E> Flipping for Ewhere
E: IntoElement,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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