Reputation: 4978
My firefox addon uses panel and when I click elsewhere panel disappears including switching the tab. Following is the code for it
var { ToggleButton } = require('sdk/ui/button/toggle');
var panels = require("sdk/panel");
var self = require("sdk/self");
var tabs = require("sdk/tabs");
var button = ToggleButton({
id: "my-button",
label: "my button",
icon: {
"16": "./icon-16.png",
"32": "./icon-32.png",
"64": "./icon-64.png"
},
onChange: handleChange
});
var panel = panels.Panel({
contentURL: "about:blank",
width: 320,
height: 480,
onHide: handleHide,
onHide: handleHide
});
function handleChange(state) {
if (state.checked) {
panel.contentURL = tabs.activeTab.url;
panel.show({
position: button
});
}
};
function handleHide() {
button.state('window', {checked: false});
};
When I click on the icon, it shows the panel above it but when the focus is out, it immediately closes and starts afresh again. How do I make sure, it wont close on loosing focus but I need to click on the widget again to hide it.
Upvotes: 0
Views: 175
Reputation: 25322
It can't be done in SDK. There are several issues to face, plus the panel wasn't implemented to work in such way. You can, however, do it manually, but you have some issues to face that are not easy. You can check my answer here: firefox add-on sdk: make panel to stay visible that also point to this WONTFIX bug: https://bugzilla.mozilla.org/show_bug.cgi?id=595040
Upvotes: 2