Is there a way use findbar for non-browser element?
I'm trying adopt findbar to use it on listbox in a prefwindow.
Is there a way use findbar for non-browser element?
I'm trying adopt findbar to use it on listbox in a prefwindow.
Unfortunately, the <findbar>
widget is really meant to be used with a browser element. You can use it with other data if you fake the necessary browser APIs but there is no guarantee whatsoever that it will continue to work in future. In particular, the APIs in question changed from synchronous to asynchonous in Firefox 26 which broke every extension that was implementing them such as Adblock Plus or Stylish.
In the implementation of the <findbar>
widget you can see what it currently expects from a browser:
Components.utils.import("resource://gre/modules/Services.jsm");
var fakeBrowser = {
finder: new Finder(),
_lastSearchString: "",
_lastSearchHighlight: false,
currentURI: Services.io.newURI("http://example.com/"),
contentWindow: null,
addEventListener: function() {}
removeEventListener: function() {},
};
This fake browser can be assigned to the findbar.browser
property. The important part here is the finder
property, normally that's a Finder
object defined by Finder.jsm
. You would want to implement your own object providing the same API of course.