Insert item to application menu from renderer process


#1

I have an electron application with a custom menu and I want to add an item that, when clicked will run a function from the renderer process. How can i add menu items from that process after setting the menu from the main process?


#2

I believe the easiest way would be to use ipcMain and ipcRenderer methods.

Also, if you need to create menus from the renderer process, you can use the remote module as covered here in Menu docs.


#3

@kysely
But how can I send a message from the main process to the renderer process? The Electron API Demos app only shows how to send from the renderer to the main and I need to do the opposite.


#4

Oh, okay—you can send message from the main process via window’s webContents object and listen to it via regular ipcRenderer.on() method.