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() {
|
2024-01-16 11:45:02 -06:00
|
|
|
launch_desktop(app);
|
2022-12-30 22:05:15 -05:00
|
|
|
}
|
|
|
|
|
2024-01-13 20:51:37 -08: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
|
|
|
}
|
|
|
|
|
2024-01-13 20:51:37 -08: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
|
|
|
}
|