BrowserWindow OnClose event #476

Open
opened 2026-01-29 16:40:46 +00:00 by claunia · 0 comments
Owner

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;


private static void OnClose(BrowserWindow browserWindow)
{
    browserWindow.Hide();
    var menu = new MenuItem[]
    {
        new MenuItem
        {
            Label = "Show",
            Click = () =>
            {
                Electron.Tray.Destroy();
                browserWindow.Show();
            }
        },
        new MenuItem
        {
            Label = "Quit",
            Click = () => Electron.App.Quit()
        }
    };

    Electron.Tray.Show("favicon.ico", menu);
    Electron.Tray.SetToolTip("Electron Demo in the tray.");
}
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; <pre><code> private static void OnClose(BrowserWindow browserWindow) { browserWindow.Hide(); var menu = new MenuItem[] { new MenuItem { Label = "Show", Click = () => { Electron.Tray.Destroy(); browserWindow.Show(); } }, new MenuItem { Label = "Quit", Click = () => Electron.App.Quit() } }; Electron.Tray.Show("favicon.ico", menu); Electron.Tray.SetToolTip("Electron Demo in the tray."); } </code></pre>
claunia added the question label 2026-01-29 16:40:46 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#476