Operating from Tray


#1

Hey All,

What I am trying to accomplish is having my application run, but when the user quits the application, I want to conditionally override the default quit behavior and do the following:

  • hide all windows
  • hide the application in the dock
  • start up the tray

At this point, the application is still running, it’s just out of the way. The tray gives the user the ability to quit the application, relaunch the application, and open the current session (in other words show the dock icon and show the windows again).

Unfortunately, I am having a hard time accomplishing this, here’s a few attempts below:

  1. listening for ‘before-quit’ on electron app, and preventing default then calling hide() on my browserwindow.
  • this doesn’t work because if your windows don’t close it never emits ‘will-quit’ *
  1. I listen for ‘close’ event on my browserwindow and hide it instead
  • this doesn’t work, before-quit gets called, I hide my window and then it doesn’t call ‘will-quit’ *

Does anyone have any idea how to get past this?


#2

bump, anyone know how to override the quit behavior correctly?


#3

The Electron Quick Start guide shows how to override the window-all-closed behavior to not quit the app on Mac. I assume that you could use a similar pattern for what you’re describing.


#4

thanks Lee, I’ll take a look