Enable/disable application menu items at runtime


#1

MenuItems in Electron have an “enabled” property that you can set when building the template with Menu.buildFromTemplate(template). Is it possible to get the application menu after it is set, and change the “enabled” property of a MenuItem object?


#2

As far as my small amount of research took me, I couldn’t find a way of doing it. I actually only change the bar on login/logout, where I also have to change some values, so just rebuilding does the job for me.

That being said, it does look like you can return an array of the menu items, and may be able to change from there. Although, I’m not sure MenuItem has any public variables to change.


#3

You can achieve this using the following direct property at runtime,
menuItem.enabled = false;

Please refer this link for more information,