Skip to main content

ButtonProps

Struct ButtonProps 

pub struct ButtonProps {
Show 17 fields pub label: String, pub accessible_name: Option<String>, pub icon: Option<Icon>, pub icon_only: bool, pub faces: Vec<String>, pub role: Option<ButtonRole>, pub toggled: Option<bool>, pub size: ControlSize, pub enabled: bool, pub description: Option<String>, pub key: Option<String>, pub count: Option<i64>, pub dot: bool, pub alert: bool, pub in_menu: bool, pub group: Option<String>, pub press: Event,
}
Expand description

A button: pressing it does one thing. Its role says what kind of thing, which decides its whole look: the window’s one primary action, a destructive one, or an ordinary one.

Fields§

§label: String

What pressing it does, in a word or two. An icon-only button is still named by it.

§accessible_name: Option<String>

How assistive technology names it, where that says more than the label shows: the charge reads “61%” beside its charging glyph and is named “61%, charging”. Unset, the label names it.

§icon: Option<Icon>

A glyph before the label, or instead of it when icon_only.

§icon_only: bool

Show only the icon, the label naming the button to assistive technology.

§faces: Vec<String>

Who is here, as their faces: up to three faces, then a face counting the rest, and nothing else on the button at any width. icon_only’s rule holds for it too: the label is the name assistive technology hears, naming the people (“Mia Clayton and Sam Okafor are here”). One press opens the roster of everyone here.

§role: Option<ButtonRole>

What kind of action it is: secondary unless said, plain for an icon-only one.

§toggled: Option<bool>

A toggle button, and whether it is on: on, it stands on a lift of its ground and is announced as pressed.

§size: ControlSize

How prominent it is: regular unless said.

§enabled: bool

Whether it can be pressed now. A button with nothing to do never can.

§description: Option<String>

Why it cannot be pressed now, where the label does not say: the requirement an action does not meet. Its tooltip, and the description assistive technology reads beside the name it announces.

§key: Option<String>

The plain key that presses it while its window has the keyboard (and, on a row’s action, while that row is selected), as the app declared it (key: "e"): the host answers it beside the pressed control’s own event. Never drawn here; the header shows it at the action’s menu row.

§count: Option<i64>

How many new things wait behind it (unread notifications, new mail), on an icon-only button: a count standing on its icon’s top-trailing corner, as an app icon’s does, and nothing at 0. The button keeps room for it, so it never covers the control beside it. The label says the count to assistive technology.

§dot: bool

Something new behind it without a number: a dot on its icon’s corner.

§alert: bool

It needs the person: the count or the dot in the warning tone, not in your colour.

§in_menu: bool

It belongs in its header’s menu rather than in the row (crate::widget::Button::in_menu).

§group: Option<String>

The run of its owner’s actions it stands in (group: "Due"), as the app names it: the header’s menu shows rows of one run together, under the run’s own row.

§press: Event

It was pressed (a click, Enter or Space, an assistive technology).

Trait Implementations§

§

impl Component for ButtonProps

§

const NAME: &'static str = "Button"

The component’s name, as code calls it.
§

fn describe() -> Description

§

fn from_source(source: &mut dyn Source) -> Result<ButtonProps, Error>

The props source gives. Read more
§

impl Default for ButtonProps

§

fn default() -> ButtonProps

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

Auto Trait Implementations§

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
§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,