remove

  • Revision slug: Extensions/Mobile/API/NativeWindow/menu/remove
  • Revision title: remove
  • Revision id: 371623
  • Created:
  • Creator: justinpotts
  • Is current revision? No
  • Comment Editorial Revision

Revision Content

The NativeWindow object is only available to privileged code running on Firefox for Android, and is intended for use by Firefox for Android add-ons.

Summary

NativeWindow.menu.add() adds an item to the main menu in Firefox for Android, returning an ID for the item. To remove the item, use NativeWindow.menu.remove(), passing in the item's ID.

Syntax

window.NativeWindow.menu.remove(menuID);

menuID
The ID of the item to remove.

Example

The following example adds a menu item with the label "Show Toast", which displays a toast notification when clicked:

function showToast(window) {  
  window.NativeWindow.toast.show("Showing you a toast", "short");  
}  
 
var menuID;  
 
function addMenuItem(window) {  
  menuID = window.NativeWindow.menu.add("Show Toast", null, function(){  
    showToast(window);   
  });  
}  
 
function removeMenuItem(window) {  
  window.NativeWindow.menu.remove(menuID);  
}

See Also

Revision Source

<div class="note">
  The <a href="/en/Extensions/Mobile/API/NativeWindow" title="https://developer.mozilla.org/en/DOM/window.NativeWindow">NativeWindow</a> object is only available to privileged code running on Firefox for Android, and is intended for use by Firefox for Android add-ons.</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p><code><a href="/en/Extensions/Mobile/API/NativeWindow/menu" title="https://developer.mozilla.org/en/DOM/window.NativeWindow.menu">NativeWindow.menu</a>.add() </code>adds an item to the main menu in <a href="/en/Mozilla/Firefox_for_Android" title="https://developer.mozilla.org/en/Mozilla/Firefox_for_Android">Firefox for Android</a>, returning an ID for the item. To remove the item, use <code>NativeWindow.menu.remove()</code>, passing in the item's ID.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<p><code><em>window.NativeWindow.menu.remove</em><em>(menuID);</em></code></p>
<dl>
  <dt>
    <code>menuID</code></dt>
  <dd>
    The ID of the item to remove.</dd>
</dl>
<h2 id="Example" name="Example">Example</h2>
<p>The following example adds a menu item with the label "Show Toast", which displays a toast notification when clicked:</p>
<pre class="brush: js">
function showToast(window) { &nbsp;
&nbsp; window.NativeWindow.toast.show("Showing you a toast", "short"); &nbsp;
} &nbsp;
&nbsp;
var menuID; &nbsp;
&nbsp;
function addMenuItem(window) { &nbsp;
&nbsp; menuID = window.NativeWindow.menu.add("Show Toast", null, function(){ &nbsp;
&nbsp;&nbsp;&nbsp; showToast(window);&nbsp; &nbsp;
&nbsp; }); &nbsp;
} &nbsp;
&nbsp;
function removeMenuItem(window) { &nbsp;
&nbsp; window.NativeWindow.menu.remove(menuID); &nbsp;
}
</pre>
<h2 id="Specification" name="Specification">See Also</h2>
Revert to this revision