2024-02-14 20:33:07 +00:00
|
|
|
//! Multiwindow example
|
|
|
|
//!
|
2024-07-24 00:49:33 +00:00
|
|
|
//! This example shows how to implement a simple multiwindow application using dioxus.
|
2024-02-14 20:33:07 +00:00
|
|
|
//! 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-31 03:05:15 +00:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
fn main() {
|
2024-01-16 17:45:02 +00:00
|
|
|
launch_desktop(app);
|
2022-12-31 03:05:15 +00:00
|
|
|
}
|
|
|
|
|
2024-01-14 04:51:37 +00:00
|
|
|
fn app() -> Element {
|
2024-01-20 08:11:55 +00:00
|
|
|
let onclick = move |_| {
|
|
|
|
let dom = VirtualDom::new(popup);
|
|
|
|
dioxus::desktop::window().new_window(dom, Default::default());
|
|
|
|
};
|
|
|
|
|
2024-01-16 19:18:46 +00:00
|
|
|
rsx! {
|
2024-01-20 08:11:55 +00:00
|
|
|
button { onclick, "New Window" }
|
2024-01-14 05:12:21 +00:00
|
|
|
}
|
2022-12-31 03:05:15 +00:00
|
|
|
}
|
|
|
|
|
2024-01-14 04:51:37 +00:00
|
|
|
fn popup() -> Element {
|
2024-01-16 19:18:46 +00:00
|
|
|
rsx! {
|
2024-01-20 08:11:55 +00:00
|
|
|
div { "This is a popup window!" }
|
2024-01-14 05:12:21 +00:00
|
|
|
}
|
2022-12-31 03:05:15 +00:00
|
|
|
}
|