2

I've tried to create new app window through window menu. But there i faced with issue that method

create_window

is not available

How can i do that?

 #![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]

use tauri::{Menu, WindowMenuEvent, Wry, Submenu, CustomMenuItem, WindowUrl, WindowBuilder};


pub fn create() -> Menu {
    let test_menu = Menu::new()
        .add_item(CustomMenuItem::new("new_window", "Create new window"));

    Menu::new()
        .add_submenu(Submenu::new("Test", test_menu))

}


pub fn handler(event: WindowMenuEvent<Wry>) {
    match event.menu_item_id() {
        "new_window" => {
            let mut window = event.window().clone();

        }
        _ => {}
    }
}


fn main() {
    tauri::Builder::default()
        .menu(create())
        .on_menu_event(handler)
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

I created menu and cloned main window(i need to create same window) in event

Snoz3f
  • 173
  • 1
  • 10
  • Seems like this function was only present before the 1.0.0 release of Tauri. You may want to use [builder](https://docs.rs/tauri/latest/tauri/window/struct.Window.html#method.builder) instead. – SirDarius Nov 18 '22 at 17:25

0 Answers0