Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 1.07 KB

File metadata and controls

38 lines (28 loc) · 1.07 KB

Button

The Button widget supports reactions to pressing/touching events. It has two methods of constructions. If the method on_press is set, the button is enabled, and is disabled otherwise. We can also set padding around the text of the button.

use iced::widget::{button, column, Button, Column};

pub fn main() -> iced::Result {
    iced::application("My app", update, view).run()
}

#[derive(Debug, Clone)]

enum Message {
    DoSomething,
}

fn update(_value: &mut u64, _message: Message) {}

fn view(_value: &u64) -> Column<Message> {
    column![
        Button::new("Disabled button"),
        button("Construct from function"),
        button("Enabled button").on_press(Message::DoSomething),
        button("With padding").padding(20),
    ]
    .into()
}

Button

➡️ Next: TextInput

📘 Back: Table of contents