TylerJames
TylerJames

Reputation: 971

Electron app OSX: List all windows when right-clicking dock icon

I've created an Electron app which is effectively a native wrapper for my web app, with some native integration. When the user clicks on external link I create a new BrowserWindow to load the request. If I then click on the main window the secondary browser window gets hidden and it is no longer obvious that the second window even exists.

If I right click on the app's dock icon it does not show that there are multiple windows associated with the app. Do I have to add new windows to this list manually? I see that there is an API to add files to the recent documents section of the dock menu, but nothing about listing windows.

Is there a way to make it so that my open Electron BrowserWindow instances appear in the dock menu as shown in the image below?

Thanks.

Chrome windows listed at top

Upvotes: 2

Views: 1611

Answers (1)

TylerJames
TylerJames

Reputation: 971

In order to get your BrowserWindows to appear in the dock menu, an example of which is shown in the question, you must include a MenuItem in your Application Menu has the 'role' set to 'window'. Example:

{
  role: 'window',
  submenu: [
    {
      role: 'minimize'
    },
    {
      role: 'close'
    }
  ]
}

Further example of creating an application menu: https://github.com/electron/electron/blob/master/docs/api/menu.md

Upvotes: 3

Related Questions