我试图显示panel
并根据button
定位它,但panel
仍显示在窗口的中央,是我错过了什么?
我可以定位panel
onclick,使其锚定到togglebutton
,但是当尝试以编程方式锚定它时,它不起作用。
main.js
..
var Button = require("./ToggleButton"),
Panel = require("sdk/panel"),
Data = require("./Data");
var panel = Panel.Panel({
width: 350,
height: 130,
contentURL: Data.get("html/view.html"),
contentScriptFile: Data.get("js/controller.js")
});
panel.port.on("selectDir", function () {
// Chrome API access, user selects a directory, then re-show the panel anchored to Panel?
panel.show({
position: Button.get()
});
});
ToggleButton.js
..
var { ToggleButton } = require("sdk/ui/button/toggle"),
Data = require("./Data"),
button;
exports.init = function() {
button = ToggleButton({
id: "widget",
label: 'Label',
icon: Data.get("images/ico-64.png"),
});
}
exports.get = function() {
return button;
}
答案 0 :(得分:2)
panel = Panel.Panel({
width: 350,
height: 130,
contentURL: Data.get("html/view.html"),
contentScriptFile: Data.get("js/controller.js"),
position: Button.get()
});
..做了伎俩。