Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

update

This article needs a technical review. How you can help.

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 update the item, use NativeWindow.menu.update(), passing in the item's ID and a set of attributes to update.

Syntax

window.NativeWindow.menu.update(menuID, options);

menuID
The ID of the item to update.
options
The Javascript object specifying the set of attributes to update. The current set of supported options are:
  • checkable - Boolean specifying whether the item should be checkable.
  • checked - Boolean specifying whether the item should be checked.
  • enabled - Boolean specifying whether the item should be enabled.
  • visible - Boolean specifying whether the item should be checkable.

Example

The following example adds a menu item with the label "Desktop Mode" which can be toggled.

var menuID;  
var isChecked = false;  
 
function addMenuItem(window) {  
  menuID = window.NativeWindow.menu.add({  
    name: "Desktop Mode",  
    icon: null,  
    checkable: true,   // specifies the toggling behavior of the item.  
    callback: function(){  
      toggleWindow(window);   
  });  
}  
 
function toggleWindow(window) {  
  isChecked = !isChecked;
  window.NativeWindow.menu.update(menuID, {
   checked: isChecked   // updates the checked state of the item.  
  });  
}  

See Also

Document Tags and Contributors

 Contributors to this page: wbamberg, gal007, MarkFinkle, sriramramani
 Last updated by: wbamberg,