Is it possible for an autocompleter to activate when its target receives focus?
many thanks in advance
Keith
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
seaside@lists.squeakfoundation.org