Neil <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Tony wrote:
> 
> >I've got thus far in my research:-
> >
> >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.
> >  
> >
> 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.
> 
> 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);

After some fishing I wondered if <listbox> could be made to do what I
want; which is: a control that does a partial match on the start of
items in a list, with the user's input as they type it.  This ended in
failure as a result of what seem to be bugs in <listbox>s created
dynamically (Bugzilla 176227).

So now I will be trying a similar technique with a simple <tree>.

I will have to get to grips with the XPCOM stuff sooner or later, so I
expect that your tips, Neil, will come in handy then - or if I can't
get <tree> to do the job, thanks.

Tony
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to