Reputation: 147
I am making a firefox add-on using the add-on sdk, also known as Jetpack.
What I need is to intercept events, especially pasting in the searchbar and the possibility of cancelling it due to user feedback. How can I register a listener that makes this possible?
Upvotes: 1
Views: 297
Reputation: 570
Use DOM Inspector add-on to find out the search bar's id.
In your source code:
var utils = require('sdk/window/utils');
var doc = utils.getMostRecentWindow().document;
var searchbar = doc.getElementById("searchbar");
searchbar.addEventListener("change", /* your callback function here */ );
Upvotes: 0
Reputation: 4537
You should be able to check for changes to the searchbar like this (from your overlay):
var searchbar = document.getElementById("searchbar");
searchbar.addEventListener("change", function(e) { // do something // }, false);
Your handler will be called whenever the contents of the searchbar change so you can take appropriate action.
Upvotes: 1