I've got thus far in my research:-This only applies to registered datasources. In this case you can use the searchSessions= attribute to specify a registered datasource. However you can also use the autocomplete's addSession method to add a manually created session.
var contractid = "@mozilla.org/autocompleteSession;1?type=my_datasource"; var session = Components.classes[contractid].getService(components. interfaces.nsIAutoCompleteSession);
But where and what would my_datasource be? Please excuse me no knowing all about this, I am still trying to learn it.
The manually created session, like the registered datasources, must implement the nsIAutoCompleteSession.idl interface. Basically this means that the autocomplete will call the three functions declared. One way of doing this is like this:
var myDatasource = {
onStartLookup: function onStartLookup(searchString, previousSearchResult, listener) {
/* build up your results (you might be able to search the previousSearchResult rather than your original data source) then send your results to the listener */
},
onStopLookup: function onStopLookup() {
/* stop sending the results to the listener. It only applies for asynchronous results */
},
onAutoComplete: function onAutoComplete(searchString, previousSearchResult, listener) {
/* this probably doesn't have to do anything, or the same as onStartLookup */
}
};
I've since discovered that you can (at least from chrome) create autocomplete results and item instances, which will simplify the rest of your code:
Components.classes['@mozilla.org/autocomplete/results;1'].createInstance(Components.interfaces.nsIAutoCompleteResults);
Components.classes['@mozilla.org/autocomplete/item;1'].createInstance(Components.interfaces.nsIAutoCompleteItem);
-- Warning: May contain traces of nuts.
_______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
