You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I set my system tray app menu with all menu items disabled at start up (as described in #2200 - Thanks @woubuc).
During execution of .setup the app checks to see if a JWT token was previously obtained and stored i.e. if the user registered previously. If yes, I need to re-enable one or more of the system tray menu items. I'm trying to do it like this:
let th = app.handle().tray_handle();
th.get_item(&"open_action".to_string()).set_enabled(true);
The problem is, at that point in the app's execution (.setup) the tray has not initialised, so I get the following runtime error:
thread 'main' panicked at 'tray not configured; use the Builder#system_tray API first.'
So the question is, how do I access the tray items to set them enabled? Can I move my check (for the JWT) out of .setup and use tray_handle().get_item(...) later in the app startup process (where?) or is there another method of access the tray from .setup?
Some similar example code:
let menu_item_1 = CustomMenuItem::new("open_action".to_string(),"Open...").disabled();let menu_item_2 = CustomMenuItem::new("close_action".to_string(),"Close").disabled();let tray_menu = SystemTrayMenu::new().add_item(menu_item_1).add_item(menu_item_2)
tauri::Builder::default().system_tray(SystemTray::new().with_menu(tray_menu)).on_system_tray_event(|app, event| match event { ...}).setup(|app| {
...
do stuff
...
ifget_JWT(){let th = app.handle().tray_handle();
th.get_item(&"open_action".to_string()).set_enabled(true);}Ok(())}).run(...).expect(...);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I set my system tray app menu with all menu items disabled at start up (as described in #2200 - Thanks @woubuc).
During execution of .setup the app checks to see if a JWT token was previously obtained and stored i.e. if the user registered previously. If yes, I need to re-enable one or more of the system tray menu items. I'm trying to do it like this:
The problem is, at that point in the app's execution (.setup) the tray has not initialised, so I get the following runtime error:
thread 'main' panicked at 'tray not configured; use the Builder#system_tray API first.'
So the question is, how do I access the tray items to set them enabled? Can I move my check (for the JWT) out of .setup and use tray_handle().get_item(...) later in the app startup process (where?) or is there another method of access the tray from .setup?
Some similar example code:
Beta Was this translation helpful? Give feedback.
All reactions