-
I'm trying to make a program that hide frontend desktop when the event send Close or Exit request and show back when user click tray icon. But when I debug printed the label of window it's empty and I've even tried to use Code: .system_tray(tray).on_system_tray_event(|app, event| {
if let tauri::SystemTrayEvent::MenuItemClick {id, .. } = event {
if let "show" = id.as_str() {
app.get_window("main").unwrap().show().unwrap();
eprintln!("ppppppp");
}
}
}).on_window_event(|event| {
if let CloseRequested { api, .. } = event.event() {
event.window().hide().unwrap();
api.prevent_close();
eprintln!("ccccccc");
}
}).build(tauri::generate_context!()).expect("error while running tauri application");
app.run(|app_handle, e| match e {
tauri::RunEvent::ExitRequested { api, .. } => {
let app_handle = app_handle.clone();
let p = app_handle.windows();
println!("{:?}", p);
api.prevent_exit();
eprintln!("eeeeeee");
},
tauri::RunEvent::WindowEvent { label, event: CloseRequested { api, .. }, .. } => {
let app_handle = app_handle.clone();
app_handle.get_window(&label).unwrap().hide().unwrap();
api.prevent_close();
let mut win_label = WIN_LABEL.lock().unwrap();
*win_label = label.clone();
eprintln!("dddddd: {}", label);
}
_ => {},
}); |
Beta Was this translation helpful? Give feedback.
Answered by
Walker-00
Sep 27, 2023
Replies: 1 comment
-
and also the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Walker-00
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and also the
app.get_window("main")
return None.