Re: Searching in a list of values (menulist, textbox)

Michael Hofer <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xpfe
Message-ID <[email protected]>
Am 06.02.12 21:54, schrieb Michael Hofer:
> Am 01.02.12 21:38, schrieb Michael Hofer:
>> Am 26.01.12 12:35, schrieb Michael Hofer:
>> Not exactly what I want. Any ideas how to access/store the id of the
>> selected entry for later retrieval (while displaying the displayValue)?
>> Is there a way to access the textbox from within the
>> 'ProviderAutoCompleteResult' (nsIAutoCompleteResult) to attach something
>> like a 'selectedId' attribute to it?
>
> I'm now trying to use the comment field of the autocomplete textbox for
> my id property (accessible via textbox.controller.getCommentAt(index)).
[...]
> Any ideas on how to get the selected index?

I finally found a way. There is an 'autocomplete-did-enter-text' 
notification which can be observed. Because this notification is sent 
before the popup closes (as opposed to the ontextentered event), the 
index of the selected element is still available in the observer. So the 
comment (or other fields) from the chosen entry can be retrieved via

   subject.controller.getCommentAt(subject.popup.selectedIndex)

in the observer.

Cost me quite some time to figure that out. Maybe it helps somebody else...

regards,
Michael
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.