multiwindow.rs 655 B

12345678910111213141516171819202122232425262728
  1. //! Multiwindow example
  2. //!
  3. //! This example shows how to implement a simple multiwindow application using dioxus.
  4. //! This works by spawning a new window when the user clicks a button. We have to build a new virtualdom which has its
  5. //! own context, root elements, etc.
  6. use dioxus::prelude::*;
  7. fn main() {
  8. launch_desktop(app);
  9. }
  10. fn app() -> Element {
  11. let onclick = move |_| {
  12. let dom = VirtualDom::new(popup);
  13. dioxus::desktop::window().new_window(dom, Default::default());
  14. };
  15. rsx! {
  16. button { onclick, "New Window" }
  17. }
  18. }
  19. fn popup() -> Element {
  20. rsx! {
  21. div { "This is a popup window!" }
  22. }
  23. }