2
0
Fork 0
mirror of https://github.com/DioxusLabs/dioxus synced 2025-02-17 14:18:27 +00:00
dioxus/examples/multiwindow.rs

29 lines
655 B
Rust
Raw Normal View History

2024-02-14 12:33:07 -08:00
//! Multiwindow example
//!
//! This exmaple shows how to implement a simple multiwindow application using dioxus.
//! This works by spawning a new window when the user clicks a button. We have to build a new virtualdom which has its
//! own context, root elements, etc.
2022-12-30 22:05:15 -05:00
use dioxus::prelude::*;
fn main() {
launch_desktop(app);
2022-12-30 22:05:15 -05:00
}
fn app() -> Element {
2024-01-20 00:11:55 -08:00
let onclick = move |_| {
let dom = VirtualDom::new(popup);
dioxus::desktop::window().new_window(dom, Default::default());
};
2024-01-16 13:18:46 -06:00
rsx! {
2024-01-20 00:11:55 -08:00
button { onclick, "New Window" }
2024-01-13 21:12:21 -08:00
}
2022-12-30 22:05:15 -05:00
}
fn popup() -> Element {
2024-01-16 13:18:46 -06:00
rsx! {
2024-01-20 00:11:55 -08:00
div { "This is a popup window!" }
2024-01-13 21:12:21 -08:00
}
2022-12-30 22:05:15 -05:00
}