<p dir="auto">I create menu in render process.  But the <code class="notranslate">console.log</code> below is not executed for top level menu items.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var remote = require('remote'),
    Menu = remote.require('menu'),
    MenuItem = remote.require('menu-item');

var tmp = [{
    label: 'menu item',
    click: function() {
        console.log('menu item clicked'); // not executed
    }
}];

var menu = Menu.buildFromTemplate(tmp);
Menu.setApplicationMenu(menu);"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">remote</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'remote'</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
    <span class="pl-v">Menu</span> <span class="pl-c1">=</span> <span class="pl-s1">remote</span><span class="pl-kos">.</span><span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'menu'</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
    <span class="pl-v">MenuItem</span> <span class="pl-c1">=</span> <span class="pl-s1">remote</span><span class="pl-kos">.</span><span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'menu-item'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">tmp</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">{</span>
    <span class="pl-c1">label</span>: <span class="pl-s">'menu item'</span><span class="pl-kos">,</span>
    <span class="pl-en">click</span>: <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'menu item clicked'</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// not executed</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">menu</span> <span class="pl-c1">=</span> <span class="pl-v">Menu</span><span class="pl-kos">.</span><span class="pl-en">buildFromTemplate</span><span class="pl-kos">(</span><span class="pl-s1">tmp</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-v">Menu</span><span class="pl-kos">.</span><span class="pl-en">setApplicationMenu</span><span class="pl-kos">(</span><span class="pl-s1">menu</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">It looks like there are plenty of options like <code class="notranslate">visible</code>, <code class="notranslate">enable</code>, etc in the <a href="https://github.com/atom/electron/blob/master/docs/api/menu-item.md">menu-item</a> but I couldn't find any way to do something with the menu after creating it. One of many failed attemps..</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var menu = Menu.buildFromTemplate(template);
menu.items[3].visible = false;
menu.items[3].enable = false;"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">menu</span> <span class="pl-c1">=</span> <span class="pl-v">Menu</span><span class="pl-kos">.</span><span class="pl-en">buildFromTemplate</span><span class="pl-kos">(</span><span class="pl-s1">template</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">menu</span><span class="pl-kos">.</span><span class="pl-c1">items</span><span class="pl-kos">[</span><span class="pl-c1">3</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">visible</span> <span class="pl-c1">=</span> <span class="pl-c1">false</span><span class="pl-kos">;</span>
<span class="pl-s1">menu</span><span class="pl-kos">.</span><span class="pl-c1">items</span><span class="pl-kos">[</span><span class="pl-c1">3</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">enable</span> <span class="pl-c1">=</span> <span class="pl-c1">false</span><span class="pl-kos">;</span></pre></div>