Creating an electron app for Mac OSX.
I don't want to close the app when I press the close button, but like other Mac apps, I want to hide the window, but I don't know how to do it.
Even if you press the close button, if you exit the application from Menu Quit, or if you shut down the OS and force the application to exit, all browser-window close events are called, so you cannot determine whether the application is closed or hidden.
Is there a way to determine why the close event occurred?
electron
By default, when you press the close button, the browserWindow quit event is called, but the app quit event does not occur.
App-side quit events are called when the app ends, such as Cmd+Q.
Electron app events are officially well written.
http://electron.atom.io/docs/v0.36.8/api/app/ #events
If the questioner receives everything he wants to do as if he doesn't want to close the app itself even if he closes the window, that's the default.If not, please review your code.You should have shut down the app when you closed the window.
If you want to display the window again when you click Dock, like other apps, why don't you get the event when the electron is activated and generate the window again?
app.on('activate', function(){
if(mainWindow==null){
mainWindow = new BrowserWindow();
}
});
If you don't want the state to return to its initial state, you can save the state of the app when you close it (you can get the event when you close it) and write a code that restores the state when you regenerate the window.
546 Understanding How to Configure Google API Key
709 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
542 Unable to install versioned in Google Colab
537 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.