Electron How to create a menu in the main process?

Electron's documentation only discusses creating menus in the Renderer process. Since the application menu bar (at least in my case) will be static for my application, it would be advisable to create once once from the main process.

Is there any way to do this?

+4
source share
1 answer

Actually, the documentation says that it is intended for use in the main process, although you can use it in Renderer with a remotemodule:

This module is the main module of the process that can be used in the rendering process through the module remote.

, , , :

const electron = require('electron');
const Menu = electron.Menu;

mainWindow = new BrowserWindow({width: 800, height: 600});

var menu = new Menu();

// Prepare your menu content ...

Menu.setApplicationMenu(menu);
+6

Source: https://habr.com/ru/post/1626565/


All Articles