Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OSX only) when window is hidden, window.on("close") not triggered on CMD + Q #3162

Closed
aretias-kr opened this issue Mar 3, 2015 · 4 comments

Comments

@aretias-kr
Copy link

            mainWindow.on("close", function (event) {
                if (event == 'quit') {
                    myapp.windowHandler.quit();
                } else {
                    mainWindow.hide();
                }
            });

I'm using the code above to handling close event and cmd + q action.
normally this code works fine.
But after mainWindow hidden, close event is not triggered.

I know that I can avoid this issue to implement menu myself.
But I think it's wrong working.

@PierBover
Copy link

I'm using this to create a global shortcut and it works even when the main window is hidden.

var gui = require('nw.gui');

var quitKeys = {
    key: "Ctrl+Q"
};

var shortcutQuit = new gui.Shortcut(quitKeys);


gui.App.registerGlobalHotKey(shortcutQuit);


shortcutQuit.on('active', function() {
   // quit your app
});

@aretias-kr
Copy link
Author

@PierBover Thanks, It seems nice solution.
But on MAC OS X, It is little wired cause application usually has quit menu on top status bar.

@PierBover
Copy link

You can add menu items on the top bar too.

https://github.com/nwjs/nw.js/wiki/Menu

@banezaklan
Copy link

I'm having the same problem. When app is hidden/minimized, the osx app menu stays active. However the app cannot be quit when selecting menu->quit. Once the app is restored the menu->quit option works again. Other osx apps also leave the menu active when minimized, but it works just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants