Can not reopen application window when I clicked x on MacOs #460

Closed
opened 2026-01-29 16:40:08 +00:00 by claunia · 5 comments
Owner

Originally created by @juliushuck on GitHub (Mar 5, 2020).

Originally assigned to: @robertmuehsig, @GregorBiswanger on GitHub.

On MacOs it is normal that when I close the window of a program, it still runs. Like when I close Safari it still runs and when I click on the icon in the dock it opens a new window. When I close the window of an Electron app and look in the dock, I can see that the application still runs. But when I click on the icon no new window gets opened. So I have to right click the icon and select quit. Then reopen the application completely. Is that normal?

Originally created by @juliushuck on GitHub (Mar 5, 2020). Originally assigned to: @robertmuehsig, @GregorBiswanger on GitHub. On MacOs it is normal that when I close the window of a program, it still runs. Like when I close Safari it still runs and when I click on the icon in the dock it opens a new window. When I close the window of an Electron app and look in the dock, I can see that the application still runs. But when I click on the icon no new window gets opened. So I have to right click the icon and select quit. Then reopen the application completely. Is that normal?
claunia added the help wantedbug labels 2026-01-29 16:40:08 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (Mar 18, 2020):

@robertmuehsig can you please test it with your mac.

@GregorBiswanger commented on GitHub (Mar 18, 2020): @robertmuehsig can you please test it with your mac.
Author
Owner

@GregorBiswanger commented on GitHub (May 10, 2020):

I have no mac - We need help for this issue please.

@GregorBiswanger commented on GitHub (May 10, 2020): I have no mac - We need help for this issue please.
Author
Owner

@BurtsevC commented on GitHub (Jun 16, 2020):

In OSX, I am usually doing something like this:

if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
	Electron.App.WindowAllClosed += ForceExit;

private void ForceExit() {
  Electron.App.Quit();
  Electron.App.Exit(0);
  Environment.Exit(0);
}

It will close the app in the dock. (Tested, It works)

If you want to minimize the window I would do something like: (Not tested)

window.addEventListener('beforeunload', function (e) {
  e.preventDefault();
  e.returnValue = '';
  ipcRenderer.send('hide-window');
});

and in C# do something like
Electron.IpcMain.On("hide-window", (args) => MainWindow.Hide());

@BurtsevC commented on GitHub (Jun 16, 2020): In OSX, I am usually doing something like this: ``` if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) Electron.App.WindowAllClosed += ForceExit; private void ForceExit() { Electron.App.Quit(); Electron.App.Exit(0); Environment.Exit(0); } ``` It will close the app in the dock. (Tested, It works) If you want to minimize the window I would do something like: (Not tested) ``` window.addEventListener('beforeunload', function (e) { e.preventDefault(); e.returnValue = ''; ipcRenderer.send('hide-window'); }); ``` and in C# do something like `Electron.IpcMain.On("hide-window", (args) => MainWindow.Hide());`
Author
Owner

@danatcofo commented on GitHub (Jan 25, 2021):

@BurtsevC , @juliushuck this is available as of 11.5.1

Mac has some idiosyncracies that us primary windows users don't really get often enough. So to add support for the Dock click...

Electron.App.On("activate", obj => {
   var hasWindows = (bool)obj;

  if (!hasWindows) {
    // create and show a new window.
 }
 else {
    // find the hidden window you want to show and show it
    // mac os defaults to showing an existing window if you do nothing here.
 }
});

This handle the case where the main window was closed leaving the app running without an accessible window.

@danatcofo commented on GitHub (Jan 25, 2021): @BurtsevC , @juliushuck this is available as of 11.5.1 Mac has some idiosyncracies that us primary windows users don't really get often enough. So to add support for the Dock click... ```csharp Electron.App.On("activate", obj => { var hasWindows = (bool)obj; if (!hasWindows) { // create and show a new window. } else { // find the hidden window you want to show and show it // mac os defaults to showing an existing window if you do nothing here. } }); ``` This handle the case where the main window was closed leaving the app running without an accessible window.
Author
Owner

@GregorBiswanger commented on GitHub (Mar 28, 2023):

🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉

With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!

@GregorBiswanger commented on GitHub (Mar 28, 2023): 🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉 With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#460