| Name | Last modified | Size | Description | |
|---|---|---|---|---|
| Parent Directory | - | |||
| chrome.manifest | 06-Jun-2010 14:54 | 265 | ||
| chrome/ | 06-Jun-2010 14:54 | - | ||
| components/ | 06-Jun-2010 14:54 | - | ||
| install.rdf | 06-Jun-2010 14:54 | 927 | ||
| makefile | 06-Jun-2010 14:54 | 437 | ||
| submenu_bug.xpi | 06-Jun-2010 14:54 | 3.0K | ||
popupshowing event.
The salient point being "When using nested submenus, make sure to check in the popupshowing event that the event corresponds to the right popup. This is because the popup events bubble so the parent menu will recieve a popupshowing event whenever it opens, or any submenus open." which I snarfed from here.
Viz a viz:
function Submenu_Bug_populate(event){
var menu = document.getElementById('submenu_bug_btn_popup');
//without this *simple* guard here, life can be very very frustrating...
if(event.target == menu){
while(menu.hasChildNodes()){ menu.removeChild(menu.firstChild); }
for(var j = 0; j < 5; j++){
if(j != 3){
menu.appendChild(createMenuItem("Choice #" + j, j));
} else {
var submenu = document.createElement("menu");
var popup = document.createElement("menupopup");
popup.appendChild(createMenuItem("Subitem A" + j , j));
popup.appendChild(createMenuItem("Subitem B" + j , j));
submenu.setAttribute("label", "Choice #" + j);
submenu.appendChild(popup);
menu.appendChild(submenu);
}
}
}
}
function createMenuItem(label, value){
var item = document.createElement("menuitem");
item.setAttribute("label", label);
item.setAttribute("class", "menuitem-iconic");
item.setAttribute("value", value);
return item;
}
Namaste!