I am trying to enter text into the text box which is right clicked and then accessed by my firefox addon context menu script. This is what I have done so far:
var cm = require("sdk/context-menu");
cm.Item({
label: "Insert Text",
context: cm.SelectorContext("input[type=text]"),
contentScript: 'self.on("click", function (node, data) {' +
' node.text = "hello"' +
'});'
});
I thought that the node was the selected element which would mean that setting node.text would enter text into the textbox but that did not work. Does anyone know how to access the textbox element and enter text into it?
Thanks
Ok I worked it out. Node does access the textbox, if you want to enter data into the textbox just do node.value = "...." like this:
var cm = require("sdk/context-menu");
cm.Item({
label: "Insert Text",
context: cm.SelectorContext("input[type=text]"),
contentScript: 'self.on("click", function (node, data) {' +
' node.value = "...."' +
'});'
});