Button

Struct Button 

Source
pub struct Button<Label, Action> { /* private fields */ }
Expand description

A button component that can be configured with a label and an action.

Implementations§

Source§

impl<Label> Button<Label, ()>

Source

pub const fn new(label: Label) -> Self

Creates a new button with the specified label.

§Arguments
  • label - The text or view to display on the button
Source§

impl<Label, Action> Button<Label, Action>

Source

pub const fn style(self, style: ButtonStyle) -> Self

Sets the visual style of the button.

§Arguments
  • style - The button style to apply
§Returns

The modified button with the style set

Source

pub fn action<H, P>(self, action: H) -> Button<Label, IntoHandler<H, P, ()>>
where H: HandlerFn<P, ()>, P: 'static,

Sets the action to be performed when the button is clicked.

§Arguments
  • action - The callback function to execute when button is clicked
§Returns

The modified button with the action set

Source

pub fn action_with<H, P, S>( self, state: &S, action: H, ) -> Button<Label, IntoHandlerWithState<H, P, (), S>>
where H: HandlerFnWithState<P, (), S>, S: 'static + Clone, P: 'static,

Sets the action to be performed when the button is clicked, with access to a state.

§Arguments
  • state - A reference to the state that the action can access.
  • action - The callback function to execute when the button is clicked.
§Returns

The modified button with the action and state set.

Trait Implementations§

Source§

impl<Label: Clone, Action: Clone> Clone for Button<Label, Action>

Source§

fn clone(&self) -> Button<Label, Action>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Label, Action> ConfigurableView for Button<Label, Action>
where Label: View, Action: Handler<()>,

Source§

type Config = ButtonConfig

The configuration type associated with this view. Read more
Source§

fn config(self) -> Self::Config

Returns the configuration for this view. Read more
Source§

impl<Label: Debug, Action: Debug> Debug for Button<Label, Action>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Label: Default, Action: Default> Default for Button<Label, Action>

Source§

fn default() -> Button<Label, Action>

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

impl<Label: Hash, Action: Hash> Hash for Button<Label, Action>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Label: PartialEq, Action: PartialEq> PartialEq for Button<Label, Action>

Source§

fn eq(&self, other: &Button<Label, Action>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Label, Action> View for Button<Label, Action>
where Label: View, Action: Handler<()>,

Source§

fn body(self, env: &Environment) -> impl View

Build this view and return the content. Read more
Source§

impl<Label: Eq, Action: Eq> Eq for Button<Label, Action>

Source§

impl<Label, Action> StructuralPartialEq for Button<Label, Action>

Auto Trait Implementations§

§

impl<Label, Action> Freeze for Button<Label, Action>
where Label: Freeze, Action: Freeze,

§

impl<Label, Action> RefUnwindSafe for Button<Label, Action>
where Label: RefUnwindSafe, Action: RefUnwindSafe,

§

impl<Label, Action> Send for Button<Label, Action>
where Label: Send, Action: Send,

§

impl<Label, Action> Sync for Button<Label, Action>
where Label: Sync, Action: Sync,

§

impl<Label, Action> Unpin for Button<Label, Action>
where Label: Unpin, Action: Unpin,

§

impl<Label, Action> UnwindSafe for Button<Label, Action>
where Label: UnwindSafe, Action: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> IdentifiableExt for T

Source§

fn use_id<F, Id>(self, f: F) -> UseId<Self, F>
where F: Fn(&Self) -> Id, Id: Ord + Hash,

Wraps the value in a UseId with the provided identification function.
Source§

fn self_id(self) -> SelfId<Self>

Wraps the value in a SelfId, making the value serve as its own identifier.
§

impl<T, U> Into<U> for T
where U: From<T>,

§

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<V> IntoView for V
where V: View,

Source§

type Output = V

The resulting View type after conversion.
Source§

fn into_view(self, _env: &Environment) -> <V as IntoView>::Output

Converts the implementing type into a View. Read more
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.