pub struct Button<Msg> { /* private fields */ }Expand description
A button: the shape is its surface colour, never brackets.
Sends its message on Enter or Space while focused, or on a click released over it, and
flashes one tone brighter to confirm. Hovered and focused buttons show the pillar in their very
first cell, before the shortcut segment and the icon (▌ ⏎ Save); the cell is reserved at rest,
so nothing moves when the pillar appears. Like every widget that is not a list, buttons never
slide. A theme padding of zero columns leaves no room for the pillar and draws none. Style keys
(pillar sets the pillar colour): button, button.<variant>, states hover, focus,
pressed, disabled; the shortcut segment uses button-key and button-key.<variant>.
Implementations§
Source§impl<Msg> Button<Msg>
impl<Msg> Button<Msg>
Sourcepub fn variant(self, variant: impl Into<String>) -> Self
pub fn variant(self, variant: impl Into<String>) -> Self
Theme variant, e.g. "primary" or "danger".
Sourcepub fn shortcut(self, label: impl Into<String>) -> Self
pub fn shortcut(self, label: impl Into<String>) -> Self
Key label drawn in a darker segment on the left, e.g. "⏎" or "ctrl s". The segment
starts with the button’s pillar cell, so the pillar stays the leftmost mark.
Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Greys the button out; it cannot be focused or pressed.
Trait Implementations§
Source§impl<Msg: Clone + 'static> Widget<Msg> for Button<Msg>
impl<Msg: Clone + 'static> Widget<Msg> for Button<Msg>
Source§fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
fn measure(&self, cx: &mut MeasureCx<'_>, available: Size) -> Size
available.Source§fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
fn event(&self, cx: &mut EventCx<'_, Msg>, event: &Event) -> bool
true when the event was used; unused key and scroll events
bubble to the parent widget.Source§fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
fn paint_overlay(&self, _cx: &mut PaintCx<'_>, _anchor: Rect)
PaintCx::request_overlay. anchor is the area the widget was painted in.Source§fn children_mut(&mut self) -> &mut [Node<Msg>]
fn children_mut(&mut self) -> &mut [Node<Msg>]
Auto Trait Implementations§
impl<Msg> Freeze for Button<Msg>
impl<Msg> RefUnwindSafe for Button<Msg>where
Option<Msg>: RefUnwindSafe,
impl<Msg> Send for Button<Msg>
impl<Msg> Sync for Button<Msg>
impl<Msg> Unpin for Button<Msg>
impl<Msg> UnsafeUnpin for Button<Msg>where
Option<Msg>: UnsafeUnpin,
impl<Msg> UnwindSafe for Button<Msg>where
Option<Msg>: UnwindSafe,
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> 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