Hi, I'm trying to dynmically build a <menu/> under a <menupopup/>. I've spent almost all day on this but cannot figure out what's wrong.
After the following code is executed in the browser (via overlay or Ted's Real-Time XUL Editor) and the submenu is popped-up: * No submenu appears * Submenus throughout the browser no longer function (e.g., View->Toolbars in FF or View->Show/Hide in Mozilla Suite) * The browser process does not terminate when the last window is closed--the process must be manually killed * FF sometimes crashes Tested in Mozilla 1.7.12 and FF 1.5.0.3 on Win XP. I could not find a buzilla bug talking explicitly about this, so I am guessing something is wrong with my code. (However, bugs 323617 and 301537 appear vaguely related) Can another pair of eyes take a look? <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script> <![CDATA[ function build(parent) { dump("in build()\n"); while (parent.hasChildNodes()) parent.removeChild(parent.firstChild); var a = document.createElement("menuitem"); a.setAttribute("label", "a"); parent.appendChild(a); var submenu = document.createElement("menu"); submenu.setAttribute("label", "submenu"); var submenupopup = document.createElement("menupopup"); //submenupopup.setAttribute("onpopupshowing", function(){}); submenu.appendChild(submenupopup); var b = document.createElement("menuitem"); b.setAttribute("label", "b"); submenupopup.appendChild(b); parent.appendChild(submenu); } ]]> </script> <toolbarbutton label="click me" type="menu"> <menupopup onpopupshowing="build(this);"/> </toolbarbutton> </window> You'll notice (in FF, at least) that the dump statement is executed once for the parent <menupopup/> and once for the sub- <menupopup/> even if I set onpopupshowing for the submeunpopup to an empty fcn. It's as if the browser enters an infinite loop of event handler callbacks. Thanks for any ideas, Eric _______________________________________________ Project_owners mailing list [email protected] http://mozdev.org/mailman/listinfo/project_owners
