1

I have an InputField search that provides search suggestions, but I want an animation necklace to be displayed while the search is 'busy'. I would also like this to be done using Dynamic rather than Manipulate.

A simplified version of the code has been provided below:

Dynamic[
 Column[{
   Row[{
     InputField[Dynamic[input], String, ContinuousAction -> True],
     Refresh[
      If[input != newInput, Animator[Appearance -> "Necklace"], 
       "Done"], TrackedSymbols :> {newInput}]
     }],
   Refresh[
   Column[Pause[2]; Characters[input], newInput = input;, 
     Frame -> All, ItemSize -> 20],
    TrackedSymbols :> {input}
    ]
   }, Spacings -> 0]
 ]

Here Pause[2] has replaced the 'busy' search calculations, and Characters[input] has replaced the search suggestions.

Currently:

  • Pause[2] is triggering twice instead of once.
  • Search suggestions and busy necklace appear simultaneously. (suggestions should appear after necklace disappears)
  • 'Busy necklace' does not animate.

End Goal:

  • 'Busy necklace' to appear immediately after input is changed.
  • Want to display an animated necklace while search is busy for the 2 seconds
  • Want the search suggestions and 'Done' message to display simultaneously

Here are some similar posts that may be helpful in solving my problem:

user12572
  • 436
  • 2
  • 9

1 Answers1

1

Update:

Solved my problem with the help of Kuba's advice; making multiple Dynamics. Code listed below, for anyone who is interested.

Note: "SynchronousUpdating -> False" allows the animator to animate while search is 'busy'.

Row[{
  Column[{
    InputField[Dynamic[input], String, ContinuousAction -> True],
    Dynamic[
     Refresh[
      If[
       input != "",
       searchImage = Animator[Appearance -> "Necklace"]; Pause[1]; 
       searchImage = "";
       Column[Characters[input], Frame -> All, ItemSize -> 20],
       ""
       ], TrackedSymbols -> {input}
      ],
     Initialization -> {input = ""; searchImage = "";}, 
     SynchronousUpdating -> False
     ]
    },
   Spacings -> 0
   ],
  Dynamic[
   Refresh[
    searchImage,
    TrackedSymbols -> {searchImage}
    ]
   ]
  }]
user12572
  • 436
  • 2
  • 9