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 "New Tab" button for Native macOS Tabs #9725

Merged
merged 1 commit into from Jun 26, 2017

Conversation

Projects
None yet
5 participants
@danielma
Contributor

danielma commented Jun 11, 2017

Adds responders for newWindowForTab to AtomApplicationDelegate and
NativeWindowMac, so that BrowserWindows with a tabbingIdentifier
will get the new tab button, and both app and window will emit a
new-tab-for-window event.

This builds on the work done in #9052

Testing app: https://github.com/danielma/electron-quick-start/tree/native-new-tab-button
Video: https://cl.ly/1W1i2K0c0509

screen shot 2017-06-11 at 2 24 07 am

Add "New Tab" button for Native macOS Tabs
Adds responders for `newWindowForTab` to `AtomApplicationDelegate` and
`NativeWindowMac`, so that `BrowserWindow`s with a `tabbingIdentifier`
will get the new tab button, and both `app` and `window` will emit a
`new-tab-for-window` event.
@zcbenz

zcbenz approved these changes Jun 26, 2017

👍

@zcbenz zcbenz merged commit 00d023c into electron:master Jun 26, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@danielma danielma deleted the danielma:dma/native-tab-new-button branch Jun 26, 2017

@tonyganch

This comment has been minimized.

Member

tonyganch commented Jun 26, 2017

@danielma, do I get it right that this button is now not optional? So apps must implement event handler for "plus" button, or clicking will do nothing?

@tonyganch

This comment has been minimized.

Member

tonyganch commented Jun 26, 2017

@bpasero

This comment has been minimized.

Contributor

bpasero commented Jun 26, 2017

This is very cool. Also curious how this actually works as consumer. I guess it is fine to let apps handle this event provided they can actually force open a new tab. Otherwise this is hard to implement correctly I guess.

@danielma

This comment has been minimized.

Contributor

danielma commented Jun 26, 2017

do I get it right that this button is now not optional? So apps must implement event handler for "plus" button, or clicking will do nothing?

@tonyganch right, it assumes that if you're opting into tabbing behavior with a tabbingIdentifier, then you'll also provide a way for a user to create a new tab on their own. If that turns out not to be a correct assumption, then electron would need to provide apps with a way to specify if the new tab button should be visible.

This is very cool. Also curious how this actually works as consumer. I guess it is fine to let apps handle this event provided they can actually force open a new tab. Otherwise this is hard to implement correctly I guess.

@bpasero I have an example of how to handle the event in the sample app, but if there's more information I could provide, please let me know

@djalmaaraujo

This comment has been minimized.

djalmaaraujo commented Jul 13, 2017

Is it possible to control the creation of a new Window or a New Tab? Also, is it possible to bind cmd+t to open a new tab instead of a whole new window?

@djalmaaraujo

This comment has been minimized.

djalmaaraujo commented Sep 11, 2017

@danielma ☝️

@danielma

This comment has been minimized.

Contributor

danielma commented Sep 11, 2017

@djalmaaraujo If I understand the question correctly, everything you need should be available in the attached sample repo.

To have a new window appear as a tab in the current window, use the same tabbingIdentifier when you create a Window.

To bind cmd+t to open a new tab, you'll probably want to use the menu API

@bpasero

This comment has been minimized.

Contributor

bpasero commented Sep 11, 2017

@danielma the same tabbing identifier is not enough as far as I recall from testing in VS Code (where we always use the same tabbing identifier for each new window). The only way for me how to make tabs appear within the same tab group is via this setting ("Prefer tabs when opening new windows" to "Always"):

image

It would be great to have a way programmatically to force opening a window either as tab or window.

Finder for example has an explicit action it seems:

image

@danielma

This comment has been minimized.

Contributor

danielma commented Sep 11, 2017

@bpasero thanks for the update. I'll have to take a look at this later and try to figure it out

danielma added a commit to danielma/electron that referenced this pull request Sep 13, 2017

feat(NativeWindowMac): addTabbedWindow
Add support for the `NSWindow addTabbedWindow` method on MacOSX

This plays nicely with the changes from electron#9052 and electron#9725

Usage samples available in [this commit][c] in my fork of
`electron-quick-start`

[c]: danielma/electron-quick-start@79f0659

danielma added a commit to danielma/electron that referenced this pull request Sep 13, 2017

feat(NativeWindowMac): addTabbedWindow
Add support for the [`NSWindow addTabbedWindow`][nsw] method on MacOSX

This plays nicely with the changes from electron#9052 and electron#9725

Usage samples available in [this commit][c] in my fork of
`electron-quick-start`

[nsw]: https://developer.apple.com/documentation/appkit/nswindow/1855947-addtabbedwindow
[c]: danielma/electron-quick-start@79f0659
@danielma

This comment has been minimized.

Contributor

danielma commented Sep 13, 2017

@bpasero I just added a PR to address the need for explicitly creating a tab #10508

danielma added a commit to danielma/electron that referenced this pull request Sep 13, 2017

feat(NativeWindowMac): addTabbedWindow
Add support for the [`NSWindow addTabbedWindow`][nsw] method on MacOSX

This plays nicely with the changes from electron#9052 and electron#9725

Usage samples available in [this commit][c] in my fork of
`electron-quick-start`

[nsw]: https://developer.apple.com/documentation/appkit/nswindow/1855947-addtabbedwindow
[c]: danielma/electron-quick-start@79f0659

danielma added a commit to danielma/electron that referenced this pull request Sep 13, 2017

feat(NativeWindowMac): addTabbedWindow
Add support for the [`NSWindow addTabbedWindow`][nsw] method on MacOSX

This plays nicely with the changes from electron#9052 and electron#9725

Usage samples available in [this commit][c] in my fork of
`electron-quick-start`

[nsw]: https://developer.apple.com/documentation/appkit/nswindow/1855947-addtabbedwindow
[c]: danielma/electron-quick-start@79f0659

zcbenz added a commit to danielma/electron that referenced this pull request Oct 3, 2017

feat(NativeWindowMac): addTabbedWindow
Add support for the [`NSWindow addTabbedWindow`][nsw] method on MacOSX

This plays nicely with the changes from electron#9052 and electron#9725

Usage samples available in [this commit][c] in my fork of
`electron-quick-start`

[nsw]: https://developer.apple.com/documentation/appkit/nswindow/1855947-addtabbedwindow
[c]: danielma/electron-quick-start@79f0659
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment