Avoid panel to autoHide in Firefox extension

2019-01-06 22:45发布

I am actually trying to develop a Firefox extension using the high level apis, and specifically trying to avoid a panel to autohide when you pick a file or when you click outside of the panel itself.

Does somebody has an idea of how to do this?

I know that it is possible using XUL, so why is this not easy using the apis?

Thank you in advance for your answers.

2条回答
霸刀☆藐视天下
2楼-- · 2019-01-06 23:25

Idea from this

var toolbarbuttonPanel = doc.createElement('panel');
toolbarbuttonPanel.setAttribute('id', 'toolbarbutton-panel');
toolbarbuttonPanel.setAttribute('type', 'arrow');
toolbarbuttonPanel.setAttribute('noautohide', 'true'); // This is important

var toolbarbuttonLabel = doc.createElement('label');
toolbarbuttonLabel.setAttribute('value', 'toolbarbutton panel');
toolbarbuttonPanel.appendChild(toolbarbuttonLabel);

var mainPopupSet = document.querySelector('#mainPopupSet');
mainPopupSet.appendChild(toolbarbuttonPanel);

Then add this on sdk action/toggle button click:

toolbarbuttonPanel.openPopup(btn);

And Noitidart's comment

查看更多
SAY GOODBYE
3楼-- · 2019-01-06 23:27

This is the offical sdk method of doing it:

let myPanel = Panel({.....})

let { getActiveView }=require("sdk/view/core");
getActiveView(myPanel).setAttribute("noautohide", true);
查看更多
登录 后发表回答