mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
BrowserWindow OnClose event #479
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AykutToprak on GitHub (May 6, 2020).
Originally assigned to: @GregorBiswanger on GitHub.
🚨 The issue tracker is not for questions 🚨
How to hide browser window and put application in Tray mode on close button clicked?
I tried as it shown below;
browserWindow.OnClose += () => OnClose(browserWindow);and OnClose action;
@GregorBiswanger commented on GitHub (May 6, 2020):
please see how to do this in native electron and try our API:
https://www.likeanswer.com/question/19825
Please let me know if everything worked out for you.
@AykutToprak commented on GitHub (May 6, 2020):
Using browserWindow in OnClose event give error as it can be seen in above image.
In my opinion the difference between native code is
event.preventDefault();of onClose event.browserWindow has been already closed in OnClose event so that it give error.
@GregorBiswanger commented on GitHub (May 7, 2020):
I built you a sample. You have to put a script in your window (HTML) when the window is closed. You prevent the app from closing and inform your code via IPC. There you create a system tray and hide the window.
Could that help you?
The script in your MainWindow (html):
The code in startup.cs:
@AykutToprak commented on GitHub (May 7, 2020):
Thank you @GregorBiswanger .
It solved the problem.
@ruohki commented on GitHub (Oct 31, 2020):
To piggyback on this problem.
In js you can do something like this in your app.js
I noticed the OnClose do not hand over any arguments to do the same in c#. Is this a missing feature?