I followed several textbooks without success. I think this is a classic example, but I can't get it to work. I can save my project, install the add-on, and I can see the context menu item "Journal Selection" when I select some text, but when I click on it, nothing happens.
exports.main = function() { var contextMenu = require("context-menu"); var request = require("request"); var selection = require("selection"); var menuItem = contextMenu.Item({ label: "Log Selection", context: contextMenu.SelectionContext(), contentScript: 'self.on("click", function () {' + ' var text = window.getSelection().toString();' + ' self.postMessage(text);' + '});', onMessage: function (selectionText) { alert(selectionText); } }); }
Even if my addon contains only one warning, the addon is installed, but the warning does not appear.
exports.main = function() { alert("Hello world"); }
Additional Information:
source share