-
Many applications need to be able to operate in the background without a visible window. A good example of this would be an app like https://justgetflux.com Currently we have implemented a tray icon, but on windows when the main windows is closed (clicking the window X) the application is killed. On MacOS, when the main window is closed the application will continue to be run (can be closed using the tray icon menu). There is an event you can listen to inside Tauri called CloseRequested, but I don't see any way to disable the logic that closes the entire Tauri application when the window is closed. Is there any good reference/example for a Tauri application that closes to the tray? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Check this tauri/examples/api/src-tauri/src/main.rs Line 233 in 51dd08a |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I also faced this problem when I migrated my app from v1 to v2 I found that when the "X" of the window is clicked then "tauri::RunEvent::ExitRequested with code = None" triggered, so when I click exit on the tray icon I give it code 0, then I handle closing the app according to the code, when the window closed anyway Here is my solution:
|
Beta Was this translation helpful? Give feedback.
Check this
tauri/examples/api/src-tauri/src/main.rs
Line 233 in 51dd08a