connors / photon

The fastest way to build beautiful Electron apps using simple HTML and CSS
photonkit.com
MIT License
10.01k stars 580 forks source link

Implement OS X Cmd+W to close windows, clicking dock icon to open windows #29

Closed ggamel closed 7 years ago

ggamel commented 8 years ago

This updates Photon to implement native OS X Window handling (e.g. Cmd+W closes windows, clicking dock icon opens windows, and Cmd+Q quits the app).

This implements what I proposed in #12.

thiakil commented 8 years ago

As it is, your code will only work on OS X; on other platforms it will always be hidden in the background, as you simply hide the window on close and the all windows closed event will never fire.

Is it also not true that in most applications when you use cmd-w or the red button that the window IS actually destroyed and when clicking the dock icon a fresh one is created (e.g. with no opened documents)?

It looks as though what you're doing with a simple window could easily be done by putting the new BrowserWindow & loadUrl in a function and call that from both the ready handler & activate handler instead of hiding it.

In your issue comment you mention audio playing in the background; hiding the window is an alternative to playing in a hidden background window, but I don't think it should be the default behaviour.

I would suggest making it a separate example file.