Question

I would like to modify the urlbar to include additional functionalities. Something like instantfox does.

For this I need 2 things:

  1. I need to listen to keypress events from my extension.
  2. I want to disable the default suggestions popup.

What would be the cleanest way to accomplish this? If possible using the addon sdk.

Was it helpful?

Solution

I have an add-on wip called Fantastic Bar which does what you want.

OTHER TIPS

This is probably the messy way you mention in your comment, but I think it's the best way to do it with the SDK

const doc = require('sdk/window/utils').getMostRecentBrowserWindow().document;
var urlBarIcons = doc.getElementById('urlbar-icons')
var btn = doc.createElement('toolbarbutton');
btn.setAttribute('id', 'foo');
btn.setAttribute('image', loc('bar.png'));
btn.addEventListener('command', function(event) {
  urlBtnClick();
}, false);
urlBarIcons.appendChild(btn);

Take a look at the examples from addon-sdk wiki, in particular the awesomebar module, how to use it. That's the easiest way to give custom suggestions on the urlbar.

I know it does not disables it (item 2 from your question) but you'll have control on what to suggest and maybe that way you don't need to to listen to keypress events (item 1 from your question).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top