change tray menu text when toggling visibility

This commit is contained in:
jfmonty2 committed 2024-01-26 21:03:45 -08:00
1 parent 70e23c7e20
commit 69f6a39396
4 files changed
+48 -15

No files matched your search

+5 -4
View File
@@ -1,15 +1,16 @@
use tauri::{
AppHandle,
Manager,
SystemTray,
SystemTrayEvent,
SystemTrayMenu,
CustomMenuItem,
};
use crate::app;
pub fn create() -> SystemTray {
let show = CustomMenuItem::new("show".to_string(), "Show");
let show = CustomMenuItem::new("show_hide".to_string(), "Show");
let quit = CustomMenuItem::new("exit".to_string(), "Exit");
let menu = SystemTrayMenu::new()
@@ -25,8 +26,8 @@ pub fn handle_event(app: &AppHandle, event: SystemTrayEvent) {
SystemTrayEvent::MenuItemClick{ id, .. } => {
match id.as_str() {
"exit" => app.exit(0),
"show" => {
let _ = app.get_window("main").map(|w| w.show());
"show_hide" => {
let _ = app::toggle_main_window(app);
}
_ => (),
}