Electron App events not firing
See original GitHub issueI’ve tried subscribing to BeforeQuit, Quitting, WillQuit, and WindowAllClosed. Regardless of the event, my code never fires when I close the Electron window.
Electron.App.BeforeQuit += SaveOptions;
Electron.App.Quitting += SaveOptions;
Electron.App.WillQuit += SaveOptions;
Electron.App.WindowAllClosed += SaveOptions;
Using version 0.0.7 on Windows 10.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
why is my eventlistener not working in electron
I am trying to learn Electron js. I have a very simple HTML in my index.html <!doctyp html> ... all the other normal...
Read more >ready-to-show event is not fired and app window doesn't ...
It's likely that this bug also affect Electron 9.x. My app is using Electron 9.3.0 and a few users have reported that the...
Read more >app | Electron
Emitted when all windows have been closed. If you do not subscribe to this event and all windows are closed, the default behavior...
Read more >How to get drop events working in Electron
Adding drag and drop for files to your Electron app should be easy ... You register a drop event listener and things are...
Read more >How to Identify and Troubleshoot Issues in Your Electron App
When developing Electron apps it can be tough to identify and troubleshoot issues. To help out with this, today we're going to take...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I coded the night long for you and fix it and implement one more feature: Prevent Quiting 😉 I synced my work on master. The next Electron.NET API Version 0.0.8 have the fix. I will write a short documentation here tomorrow. I´m tired now.
Enjoy!
You can execute your logic before the application will exit now:
Calling args.PreventDefault() will prevent the default behaviour, which is terminating the application:
The default behavior in Electron.NET is to quit the app on window all closed. If the user pressed Cmd + Q, or the developer called Electron.App.Quit(), Electron will first try to close all the windows and then emit the Electron.App.WillQuit event, and in this case the Electron.App.WindowAllClosed event would not be emitted. To deactivate the default behavior, set the Electron.WindowManager.IsQuitOnWindowAllClosed to false. The Electron.App.WindowAllClosed event would work.
Enjoy!