mozilla

update

This article is in need of a technical review.

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, MarkFinkle, gal007, sriramramani
Last updated by: gal007,
Hide Sidebar