Autocompleter activate on receiving focus

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Autocompleter activate on receiving focus

keith1y
Is it possible for an autocompleter to activate when its target receives
focus?

many thanks in advance

Keith
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Autocompleter activate on receiving focus

Lukas Renggli
> Is it possible for an autocompleter to activate when its target  
> receives
> focus?

Call the #activate method of the autocompleter when the text input  
receives focus. In SUAutocompletionTest I quickly hacked this as  
follows:

renderContentOn: html
        html paragraph: 'Start to type a Smalltalk class-name:'.
        html paragraph: [
                html textInput
                        id: 'text';
                        value: text;

                        " the activation "
                        onFocus: (html autocompleter
                                alias: 'autocompleter';
                                activate);
                        callback: [ :value | text := value ].
                html div
                        class: 'autocomplete';
                        script: (html autocompleter

                                " the autocompleter needs a name "
                                assignTo: 'autocompleter';
                                element: 'text';
                               
                                " normally the autocompleter doesn't start before 2 characters  
have been typed "
                                minChars: 0;
                                onSelected: (html request
                                        triggerFormElement: 'text');
                                on: #renderListOn: of: self) ]

You also need to update the list renderer so that it actually displays  
something in the empty case:

renderListOn: html
        | items |
        items := Smalltalk allClasses.
        text isEmpty ifFalse: [
                items := items select: [ :each | each name includesSubstring: text  
caseSensitive: false ] ].
        html unorderedList list: (items first: (items size min: 10))

Hope this helps,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
--
Lukas Renggli
http://www.lukas-renggli.ch

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Autocompleter activate on receiving focus

keith1y
Cool, thanks Lukas, I had not seen the alias: or assignTo: calls before.

One for the scriptaculous cook book.

Thanks again

Keith

> Hope this helps,
> Lukas
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside