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

🍎 Add 'Hide' to App API for OS X only #4271

Merged
merged 3 commits into from
Feb 1, 2016
Merged

Conversation

thingsinjars
Copy link
Contributor

When creating a popover window via global hotkey, you might want to return focus to the previous app after closing all windows.

For example:
http://stackoverflow.com/questions/22081215/return-focus-to-previous-apps-window-after-makekeyandorderfront

Without app.hide(), you need to interact (click on the window or cmd-tab away and back) to refocus.
without-hide

With app.hide(), you can return focus directly (gif says "hide before quit", should be "hide before close"):
with-hide

I don't think there's an equivalent for Linux or Windows so I've only done this for OS X and tagged it as such in the docs.

@thingsinjars
Copy link
Contributor Author

I had a look at the solution for hiding mentioned in #3694 but that doesn't work in the case where the app is a menubar-only app without a menu. In this case, even pressing cmd-H doesn't hide the app so it really needs an api call for it.

@thingsinjars
Copy link
Contributor Author

I also added in the call for app.show(). It doesn't automatically focus the app window again as it simply passes through to [NSApp unhide:nil];. It's always possible to just call app.focus() afterwards, anyway.

@zcbenz
Copy link
Member

zcbenz commented Feb 1, 2016

👍

zcbenz added a commit that referenced this pull request Feb 1, 2016
🍎 Add 'Hide' to App API for OS X only
@zcbenz zcbenz merged commit 457c7f5 into electron:master Feb 1, 2016
@zcbenz zcbenz mentioned this pull request Feb 1, 2016
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

Successfully merging this pull request may close these issues.

None yet

2 participants