bobbyrne01
bobbyrne01

Reputation: 6745

Anchor Panel to a ToggleButton on show?

I'm trying to show a panel and I've positioned it according to button, but the panel still shows in the center of the window, am i missing something?

I can position the panel onclick so its anchored to togglebutton, but when trying to anchor it programmatically it does not work.

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;
}

Upvotes: 2

Views: 86

Answers (1)

bobbyrne01
bobbyrne01

Reputation: 6745

panel = Panel.Panel({
    width: 350,
    height: 130,
    contentURL: Data.get("html/view.html"),
    contentScriptFile: Data.get("js/controller.js"),
    position: Button.get()
});

.. did the trick.

Upvotes: 2

Related Questions