I'm using a command for both in the overlay like this -
Code: Select all
<commandset>
<command id="myCommand" />
</commandset>
<menupopup id="menu_ToolsPopup">
<menuitem id="menu-id" class="menu-iconic"
label="&menu-label;"
insertafter="appmenu_addons" command="myCommand" />
</menupopup>
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="button-id"
class="toolbarbutton-1 chromeclass-toolbar-additional"
label="&button.label;"
command="myCommand" />
</toolbarpalette>
Code: Select all
openWindow: function() {
var windowtype = "mywindow";
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
var existingWindow = wm.getMostRecentWindow(windowtype);
var windowref = null;
if (existingWindow) {
existingWindow.focus();
}
else {
windowref = window.open("chrome://myextension/content/mywindow.xul", "mywindow",
"chrome,width=640,height=480,resizable=yes,dialog,alwaysRaised,centerscreen");
}
document.getElementById('myCommand').setAttribute("disabled","true");
windowref.addEventListener("unload",closeWindow,false);
},
closeWindow:function (){
console.log("Inside window close");
document.getElementById('CmdSetPMPlayerOpenWindow').removeAttribute("disabled");
}
Also, the window close listener is called twice, both when opening and closing, why?