Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 860 Bytes

explanation_of_sandbox_trait.md

File metadata and controls

46 lines (34 loc) · 860 Bytes

Explanation of Sandbox Trait

Sandbox works as follows.

Sandbox trait

This can also be seen in the following code.

#[derive(Debug, Clone)]
enum Message {
    // ...
}

struct MyApp {
    // ... (Some fields for the app state)
}

impl Sandbox for MyApp {
    type Message = Message;

    fn new() -> Self {
        Self {
            // ...
        }
    }

    fn title(&self) -> String {
        // Title of the window
    }

    fn update(&mut self, message: Self::Message) {
        match message {
            // Update logic
        }
    }

    fn view(&self) -> iced::Element<Self::Message> {
        // View logic
    }
}

➡️ Next: Adding Widgets

📘 Back: Table of contents