Bug 858399 - solution adds context menu to panels

Context menu only shows when contextMenu: true in panel constructor (defaults to false)

Also added get contextMenu property from panel

Also added ability to temporarily change contextMenu property setting in
the panel show(options) function

EXAMPLE USAGE:
var { ToggleButton } = require('sdk/ui/button/toggle');
var panels = require("sdk/panel");

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: "https://news.ycombinator.com",
  width: 500,
  height: 600,
  onHide: handleHide,
  contextMenu: true   //initial contextMenu setting, defaults to false
});

function handleChange(state) {
  if (state.checked) {
    panel.show({
      position: button,
      contextMenu: false  //override contextMenu constructor setting temporarily
    });
  }
}

function handleHide() {
  console.log("panel.contextMenu:"+panel.contextMenu);  //read the current contextMenu setting
  button.state('window', {checked: false});
}

Okay thanks Ben, I'll udpate that ASAP


Date: Tue, 8 Jul 2014 14:28:44 -0700
From: notifications@github.com
To: addon-sdk@noreply.github.com
CC: ray_engelking@hotmail.com
Subject: Re: [addon-sdk] Bug 858399 - solution adds context menu to panels (#1541)

In lib/sdk/panel/utils.js:

> @@ -210,6 +210,14 @@ function show(panel, options, anchor) {
>    // if focus is set to false
>    panel.setAttribute("noautofocus", !options.focus);
>  
> +  // Prevent the panel from showing the context menu
> +  // if contextMenu is set to false
> +  if(options.contextMenu) {
> +    panel.setAttribute("context", "contentAreaContextMenu");
> +  } else {
> +	panel.removeAttribute("context");

tab here should be spaces


—
Reply to this email directly or view it on GitHub.