mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
103 lines
5.2 KiB
HTML
103 lines
5.2 KiB
HTML
---
|
|
layout: docs
|
|
title: MenuManager
|
|
edit_url: "https://github.com/nylas/N1/blob/master/src/menu-manager.coffee"
|
|
---
|
|
|
|
<h2>Summary</h2>
|
|
|
|
<div class="markdown-from-sourecode">
|
|
<p><p>Provides a registry for menu items that you'd like to appear in the
|
|
application menu.</p>
|
|
<p>An instance of this class is always available as the <code>atom.menu</code> global.</p>
|
|
<h2 id="menu-cson-format">Menu CSON Format</h2>
|
|
<p>Here is an example from the <a href="https://github.com/atom/tree-view/blob/master/menus/tree-view.cson">tree-view</a>:</p>
|
|
<pre><code class="lang-coffee"><span class="hljs-list">[
|
|
{
|
|
<span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'View</span>'
|
|
<span class="hljs-variable">'submenu</span><span class="hljs-variable">':</span> <span class="hljs-list">[
|
|
{ <span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'Toggle</span> Tree View', <span class="hljs-variable">'command</span><span class="hljs-variable">':</span> <span class="hljs-variable">'tree-view:toggle</span>' }
|
|
]
|
|
}
|
|
{
|
|
<span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'Packages</span>'
|
|
<span class="hljs-variable">'submenu</span><span class="hljs-variable">':</span> <span class="hljs-list">[
|
|
<span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'Tree</span> View'
|
|
<span class="hljs-variable">'submenu</span><span class="hljs-variable">':</span> <span class="hljs-list">[
|
|
{ <span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'Focus</span>', <span class="hljs-variable">'command</span><span class="hljs-variable">':</span> <span class="hljs-variable">'tree-view:toggle-focus</span>' }
|
|
{ <span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'Toggle</span>', <span class="hljs-variable">'command</span><span class="hljs-variable">':</span> <span class="hljs-variable">'tree-view:toggle</span>' }
|
|
{ <span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'Reveal</span> Active File', <span class="hljs-variable">'command</span><span class="hljs-variable">':</span> <span class="hljs-variable">'tree-view:reveal-active-file</span>' }
|
|
{ <span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'Toggle</span> Tree Side', <span class="hljs-variable">'command</span><span class="hljs-variable">':</span> <span class="hljs-variable">'tree-view:toggle-side</span>' }
|
|
]
|
|
]
|
|
}
|
|
]</span></span></span></span>
|
|
</code></pre>
|
|
<p>Use in your package's menu <code>.cson</code> file requires that you place your menu
|
|
structure under a <code>menu</code> key.</p>
|
|
<pre><code class="lang-coffee"><span class="hljs-variable">'menu</span><span class="hljs-variable">':</span> <span class="hljs-list">[
|
|
{
|
|
<span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'View</span>'
|
|
<span class="hljs-variable">'submenu</span><span class="hljs-variable">':</span> <span class="hljs-list">[
|
|
{ <span class="hljs-variable">'label</span><span class="hljs-variable">':</span> <span class="hljs-variable">'Toggle</span> Tree View', <span class="hljs-variable">'command</span><span class="hljs-variable">':</span> <span class="hljs-variable">'tree-view:toggle</span>' }
|
|
]
|
|
}
|
|
]</span></span>
|
|
</code></pre>
|
|
<p>See <a href='#add'>add</a> for more info about adding menu's directly.</p>
|
|
</p>
|
|
</div>
|
|
|
|
<ul>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Instance Methods</h3>
|
|
|
|
<h4 id=add class="function-name">
|
|
add(<span class="args"><span class="arg">items</span></span>) <a href="#add" class="link"></a>
|
|
</h4>
|
|
|
|
<div class="function-description markdown-from-sourecode">
|
|
<p><p>Adds the given items to the application menu.</p>
|
|
</p>
|
|
</div>
|
|
|
|
<strong>Parameters</strong>
|
|
<table class="arguments">
|
|
<tr>
|
|
<th>Argument</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
<tr>
|
|
<td style="width:15%;">
|
|
<em>items</em>
|
|
</td>
|
|
<td class="markdown-from-sourecode">
|
|
|
|
<p>An <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/array'>Array</a> of menu item <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/object'>Object</a>s containing the keys:</p>
|
|
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<strong>Returns</strong>
|
|
<table class="arguments">
|
|
<tr>
|
|
<th>Return Values</th>
|
|
</tr>
|
|
<tr><td class="markdown-from-sourecode"><p>Returns a {Disposable} on which <code>.dispose()</code> can be called to remove the
|
|
added menu items.</p>
|
|
</td></tr>
|
|
</table>
|
|
<h4 id=update class="function-name">
|
|
update(<span class="args"></span>) <a href="#update" class="link"></a>
|
|
</h4>
|
|
|
|
<div class="function-description markdown-from-sourecode">
|
|
<p><p>Refreshes the currently visible menu. </p>
|
|
</p>
|
|
</div>
|