There are three controls in the following code: the first one is a "stand-alone" one and the other two are based on the list angle. When one of the "angles" becomes active, all of them do the same. How to prevent it?

DynamicModule[{angle = Array[0 &, 2]},
      Slider[Dynamic[x], {0, 2 Pi}], Dynamic[{x, ControlActive["a", "Inactive"]}]}, 
       With[{i = #2[[1]]}, {Slider[Dynamic[angle[[i]]], {0, 2 Pi}], 
          Dynamic[{angle[[i]], ControlActive["Active", "Inactive"]}]}] &, angle]]}]]

Mathematica graphics

  • 2
    $\begingroup$ closely related: How to track Part of Symbol [...] $\endgroup$
    – Kuba
    Commented Feb 28, 2016 at 9:52
  • $\begingroup$ @Kuba Ugh. Dynamic is a wild beast :( $\endgroup$ Commented Feb 28, 2016 at 10:00
  • $\begingroup$ "Dynamic is a wild beast" -- Yes, perhaps it is the proverbial dancing bear, of which was said: we should be grateful that it dances at all and not expect it to dance gracefully. $\endgroup$
    – m_goldberg
    Commented Feb 28, 2016 at 15:20

1 Answer 1


It looks that ControlActive treats angle as a one variable which will be same for both ControlActive.

See if this help:

 DynamicModule[{angle = Array[0 &, 2]}, 
   Column[{Row@{Slider[Dynamic[x], {0, 2 Pi}], 
       Dynamic[{x, ControlActive["a", "Inactive"]}]}, 
       With[{i = #2[[1]]}, {DynamicModule[{y}, 
           Row@{Slider[Dynamic[y, (angle[[i]] = y = #) &], {0, 2 Pi}],
              Dynamic[{y, ControlActive["Active", "Inactive"]}]}]}] &,
  • $\begingroup$ Yep! It works :) I don't find the idea of nesting neat but .... :).Thans! $\endgroup$ Commented Feb 28, 2016 at 0:18
  • $\begingroup$ @Dr. belisarius I am trying to create different variable for each controller. The only way I have (for automatic goal) is to use DynamicModule. It is something like this angle={a,b} and then work with a and b instead of working with angle itself. $\endgroup$ Commented Feb 28, 2016 at 0:24
  • $\begingroup$ In my real problem I don't know a priori how many "angles" I will have $\endgroup$ Commented Feb 28, 2016 at 1:26
  • $\begingroup$ That is why is use DynamicModule to generate different variable for each element of angle $\endgroup$ Commented Feb 28, 2016 at 1:34
  • 1
    $\begingroup$ yes,yes. Your answer works.I was referring to your previous comment "I am trying to create different variable" $\endgroup$ Commented Feb 28, 2016 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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