0
我有一个上下文菜单,可以扩展到两个子菜单。我想点击子菜单来显示弹出式菜单,我将允许用户输入。我已经梳理了网络的一些帮助,但徒劳无功。这是我的main.js的样子;Firefox Add-on sdk:右键单击子菜单上下文以显示面板
/**
* main.js file defining context mmenu using Item and Menu
*
**/
var cm = require("sdk/context-menu");
var data = require("sdk/self").data;
/**
* Construct a panel, loading its content from the "text-entry.html"
* file in the "data" directory, and loading the "get-text.js" script
* into it.
**/
var textEntry = require("sdk/panel").Panel({
contentURL: data.url("text-entry.html"),
contentScriptFIle: data.url("get-text.js")
});
var quickInkItem = cm.Item({
label: "Quick Ink",
contentScriptFile: data.url("testscript.js")
});
var inkToBoardItem = cm.Item({
label: "Ink to Board",
onClick: handleClick, //Does not work
contentScriptFile: data.url("testscript.js")
});
var inkLibsMenu = cm.Menu({
label: "inkLibs",
context: cm.SelectorContext("a[href]"),
items: [quickInkItem, inkToBoardItem]
});
//Show panel when user clicks the ink-to-Board submenu
function handleClick(){
textEntry.show();
}
//When the panel is displayed, it generates an event called 'show'
//We will listen to that event and when it happens, send our own "show" event
//to the panel's script, so the script can prepare the panel for display
textEntry.on('show', function(){
textEntry.port.emit("show");
});
//Listen for the messages called "text-entered" coming from the content script
//The message payload is the text the user entered.
textEntry.port.on("text-entered", function(text){
console.log(text);
textEntry.hide();
});