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