[][src]Struct coffee::ui::widget::button::Button

pub struct Button<'a, Message> { /* fields omitted */ }

A generic widget that produces a message when clicked.

It implements Widget when the associated core::Renderer implements the button::Renderer trait.

Example

use coffee::ui::{button, Button};

pub enum Message {
    ButtonClicked,
}

let state = &mut button::State::new();

Button::new(state, "Click me!")
    .on_press(Message::ButtonClicked);

Button drawn by the built-in renderer

Methods

impl<'a, Message> Button<'a, Message>[src]

pub fn new(state: &'a mut State, label: &str) -> Self[src]

Creates a new Button with some local State and the given label.

The default Class of a new Button is Class::Primary.

pub fn width(self, width: u32) -> Self[src]

Sets the width of the Button in pixels.

pub fn fill_width(self) -> Self[src]

Makes the Button fill the horizontal space of its container.

pub fn align_self(self, align: Align) -> Self[src]

Sets the alignment of the Button itself.

This is useful if you want to override the default alignment given by the parent container.

pub fn class(self, class: Class) -> Self[src]

Sets the Class of the Button.

pub fn on_press(self, msg: Message) -> Self[src]

Sets the message that will be produced when the Button is pressed.

Trait Implementations

impl<'a, Message> Debug for Button<'a, Message> where
    Message: Debug
[src]

impl<'a, Message, Renderer> From<Button<'a, Message>> for Element<'a, Message, Renderer> where
    Renderer: Renderer,
    Message: 'static + Copy + Debug
[src]

impl<'a, Message, Renderer> Widget<Message, Renderer> for Button<'a, Message> where
    Renderer: Renderer,
    Message: Copy + Debug
[src]

Auto Trait Implementations

impl<'a, Message> RefUnwindSafe for Button<'a, Message> where
    Message: RefUnwindSafe

impl<'a, Message> Send for Button<'a, Message> where
    Message: Send

impl<'a, Message> Sync for Button<'a, Message> where
    Message: Sync

impl<'a, Message> Unpin for Button<'a, Message> where
    Message: Unpin

impl<'a, Message> !UnwindSafe for Button<'a, Message>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SetParameter for T

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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