0

I want to catch any event from TAURI rust app in main.rs to handle notification function.

Story is:

Just catch an event(it can be click, mouseEnter, DOMContentLoaded etc..) and trigger another function inside main.rs which is gonna be notification function.

Solution 1 Problem 1 is:

#[tauri::command]
async fn open_settings_window(app: tauri::AppHandle) -> Result<(), String> {
    let window = tauri::WindowBuilder::new(&app, "label", tauri::WindowUrl::External("https://tauri.app/".parse().unwrap()))
        .fullscreen(false)
        .resizable(true)
        .title("none")
        .center()
        .build()
        .map_err(|err| {
            println!("Failed to create Window {}", err);
            "Failed to create Window".to_string()
        })?;

    window.listen("click", move |event| {
println!("clicked");
    });
    println!("Window created successfully!");
    Ok(())
}

I tried to handle click event and printin something, as weird there was no any error in terminal but "clicked" not printed.

Solution 2 Problem 2 is:

window.onload = () => {

  


  function showNotification() {
    Notification("notif", "notiff")
  
  
 
  
}
}

When I try to execute notifications from preload.js I am getting this error: Uncaught(in promise) Scope is not defined for window 'label' and URL See https://tauri.app/v1/api/config/#securityconfig.dangerousremotedomainipcaccess

My idea was execute notification and handle events from preload.js from window.

cafce25
  • 15,907
  • 4
  • 25
  • 31

0 Answers0