Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 959 Bytes

first_app.md

File metadata and controls

38 lines (26 loc) · 959 Bytes

First App - Hello World!

We need a struct to implement Sandbox, and call its run method from main. All widgets should be placed inside the view method.

use iced::{Sandbox, Settings};

fn main() -> iced::Result {
    MyApp::run(Settings::default())
}

struct MyApp;

impl Sandbox for MyApp {
    type Message = ();

    fn new() -> Self {
        Self
    }

    fn title(&self) -> String {
        String::from("My App")
    }

    fn update(&mut self, _message: Self::Message) {}

    fn view(&self) -> iced::Element<Self::Message> {
        "Hello World!".into()
    }
}

First app

➡️ Next: Explanation of Sandbox Trait

📘 Back: Table of contents