I'm having problems with CustomizableUI.createWidget({ type: "custom" } ) .
When I was using Firefox 128 with xiaoxiaoflood's uc loader, it worked fine.
Recently I upgraded to Firefox 140 and migrated to your uc loader.
I found this code has problem:
console.debug("cusotom_widget.uc.js");
function funcA() {
console.log('funcA()');
console.log('123');
}
function funcB() {
console.log('funcB()');
console.log('456');
}
function funcC() {
console.log('funcC()');
console.log('789');
}
ChromeUtils.importESModule("resource:///modules/CustomizableUI.sys.mjs")
CustomizableUI.createWidget({
type: "custom",
id: "abcd", // button id
defaultArea: CustomizableUI.AREA_NAVBAR,
removable: true,
onBuild: function (doc) {
let btn = doc.createXULElement('toolbarbutton');
btn.id = 'abcd';
btn.label = 'btn abcd';
btn.tooltipText = 'btn abcd';
btn.type = 'menu';
btn.style.width = '20px';
btn.style.height = '20px';
btn.onclick = funcA;
let mp = doc.createXULElement("menupopup");
mp.addEventListener('popupshowing', funcB);
let menuitem = doc.createXULElement("menuitem");
menuitem.label = "menu item text";
menuitem.onclick = funcC;
mp.appendChild(menuitem);
btn.appendChild(mp);
return btn;
},
});
Steps to reproduce:
- Run Firefox. Open Browser Toolbox (
ctrl+shift+alt+I)
- Click the custom widget created by above uc.js code. Menu pops up. Click the menu item.
funcA() ~ funcC() logs can appear in console. Events can trigger.
- Close Browser Toolbox
- Firefox Menu -> New Window. Open a 2nd window.
- Close the 1st window.
- Open Browser Toolbox from the 2nd window
- Try step 2 again. Now no logs can appear. Events
funcA() ~ funcC() can't trigger
It seems that when the 1st window is closed, events or functions funcA() ~ funcC() are destroyed. (If keep 2 Firefox main windows open, events can trigget on both windows)
I need to use type: custom when creating custom widget, so I can't use onCommand like general widget.
Any solutions?
I'm having problems with
CustomizableUI.createWidget({ type: "custom" } ).When I was using Firefox 128 with xiaoxiaoflood's uc loader, it worked fine.
Recently I upgraded to Firefox 140 and migrated to your uc loader.
I found this code has problem:
Steps to reproduce:
ctrl+shift+alt+I)funcA()~funcC()logs can appear in console. Events can trigger.funcA()~funcC()can't triggerIt seems that when the 1st window is closed, events or functions
funcA()~funcC()are destroyed. (If keep 2 Firefox main windows open, events can trigget on both windows)I need to use
type: customwhen creating custom widget, so I can't useonCommandlike general widget.Any solutions?