InputAutocomplete
InputAutocomplete[autocompleteFunction_, opts___] _EventObject
InputAutocomplete[autocompleteFunction_, default_String, opts___] _EventObject
renders an input field (InputText) with autocomplete generated by autocompleteFunction
. This handler function should have the following structure
autocompleteFunction[input_String, callBack_] := With[{},
...
callBack[results]
];
where results
is a sorted List
of strings.
note
cbk
may return False
to cancel autocompletion
Options
"Label"
A text-label for the widget
"ClearOnSubmit"
Keeps or clears out the input field when a users submitted the result. By the default is True
.
Event generation
It fires two patterns
"Entered"
gives a string, which was entered by a user"Selected"
gives a string, which was picked up by a user from the list, generated byautocompleteFunction
Example
Find words starting with a given letters and speak them
EventHandler[InputAutocomplete[Function[{data, cbk},
cbk[DictionaryLookup[data<>"*", 6]];
], "ClearOnSubmit"->False], Function[text,
SpeechSynthesize[text, GeneratedAssetLocation -> None] // EmitSound
]]
Here we use a wild-card pattern, which does not differentiate between Entered
and Selected
there.