Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.72 KB

initializing_a_different_window.md

File metadata and controls

48 lines (36 loc) · 1.72 KB

Initializing A Different Window

We can use window::Settings to change the properties of the window (such as position and size) when we call run of a Sandbox or Application. Developers might be interested in reading the document of window::Settings for other properties.

use iced::{window, Point, Sandbox, Settings, Size};

fn main() -> iced::Result {
    MyApp::run(Settings {
        window: window::Settings {
            size: Size {
                width: 70.,
                height: 30.,
            },
            position: window::Position::Specific(Point { x: 50., y: 60. }),
            ..window::Settings::default()
        },
        ..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".into()
    }
}

Initializing a different window

➡️ Next: Changing The Window Dynamically

📘 Back: Table of contents