I'd like to have an InputField with "dynamic" word autocompletion from a list : if I start to type some letters in the field I want the autocomplete suggestion updated. To do that I use the following code :

ListOfName = {"Steve", "Stan"}
InputField[Dynamic[f], String, ContinuousAction -> True, FieldCompletionFunction -> (Select[ListOfName,     StringStartsQ[ToString[f], IgnoreCase -> True]] &)]

It almost works but "one step too late", the ContinuousAction option seems to take into account the last letter but one instead of last. Example : if I type "Ste" in the field the FieldCompletionFunction suggest "Steve" and "Stan". I need to add the "v" (so "Stev" to have only "Steve" suggested.

Any idea to solve this ?

Thank You !


1 Answer 1


You have several issues. One is that the list of names contains only a single name ("Steve, Stan"). The other is that you are using f in your function. It would be better to use a pure function instead, something like:

    FieldCompletionFunction->Function@Pick[ListOfName, StringStartsQ[ListOfName, #]]

The ContinuousAction rule is superfluous for String types, as is the ToString.

  • $\begingroup$ Thank a lot ! yes the missing " was a typo. Just to be sure (not everthing about Mathematica syntax is clear to me !) can you confirm that for parameters expecting a function (like FieldCompletionFunction) the argument (#) is the first parameter (Dynamic[f]) and so we don't need to use & to evaluate it explicitly? (This is because I did not understand this I was using f ). $\endgroup$
    – Dalnor
    Mar 26, 2020 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.