I am using Tauri's WindowBuilder to try and create a new window in Rust. While I was able to generate a blank window, I am unable to:
- display any content on the window
- make the window close
I am fairly new with Rust and Tauri so forgive me if these problems seem trivial. There does not seem to be much about it online, so I was hoping someone out there could help me out. Thank you in advance.
Here is the command I have written within /src-tauri/src/main.rs to open what will become a settings window:
#[tauri::command]
fn open_settings_window(app: AppHandle) -> Result<(), String> {
let result = WindowBuilder::new(&app, "settings", WindowUrl::App("Settings.tsx".into()))
.fullscreen(false)
.resizable(true)
.title("Settings")
.center()
.build();
match result {
Ok(_) => {
println!("Window Created Successfully!");
Ok(())
}
Err(err) => {
println!("Failed to Create Window {}", err);
Err("Failed to create Window".to_string())
}
}
}
Within the main function I have created the necessary invoke handler:
.invoke_handler(tauri::generate_handler![open_settings_window])
Within my App.tsx file, the window is set to open onClick in the following manner:
<button type='button' onClick={() => invoke('open_settings_window')}>SETTINGS</button>
What I have tried:
- I have tried changing the WindowUrl::App() path to a static html file as well as a .tsx file as show above and nothing will display in the window. (even with path navigation like ../ or ./ etc.)
- I have explored the WindowBuilder docs to find a solution and there is none that are apparent to me: https://docs.rs/tauri/latest/tauri/window/struct.WindowBuilder.html
Please help!