Problem with TogglerBar in a Module

Hello Community,
I have the following problem. From a list of words I want to choose some and process the chosen words later on. My attempt is as follows (I´m not very experienced with such problems, especially with Dynamic, so maybe there is a much simpler solution):

choose[words_] := DynamicModule[{x, temp = words},
{TogglerBar[Dynamic@x, temp]; Dynamic@x}
… further processing of x …
]

I experimented with Dynamics (as you see) but with no effort. I want to get a list of chosen words. Does anyone have a hint for me - solution would be great :wink:

Greetings from Germany

Mike

Try starting from the following. It is based on your trial. Compare it with yours to see the modificaitons that were needed to make it work.
I hope this helps…
–David

chooseWords[words : {_String ..}] :=
 DynamicModule[{x = {}, temp = words},
  {TogglerBar[Dynamic@x, temp], 
   Dynamic@x}]

Make use of it, for example, like the following

chooseWords[{"aword", "bword", "cword", "dword"}]

I assumed you wanted to be restricted to Strings, but that is not necessary in order to make it work.

Hello David,

thank you for the answer this is helpful, but not the whole solution. The problem is, that I want to process the output (i.e. x) after having chosen words via TogglerBar, the structure of the module (or DynamicModule?) ist somewhat like:

choosewords[words : {_String ..}] := Module[{list = words, out = {}},
  out = chooseWords[list]; (* Here is your function*)
  out = Take[out, 1]; (* here some more code, 
  just an example....*)
  
  ]

If I put the semicolon after the function, I get no output. I´m not very familiar, as you see, with user-interfaces, this is my first attempt :wink:

Greetings Mike