6

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]},
 Panel@Dynamic@
   Column[{Row@{
      Slider[Dynamic[x], {0, 2 Pi}], Dynamic[{x, ControlActive["a", "Inactive"]}]}, 
   Grid[
    MapIndexed[
       With[{i = #2[[1]]}, {Slider[Dynamic[angle[[i]]], {0, 2 Pi}], 
          Dynamic[{angle[[i]], ControlActive["Active", "Inactive"]}]}] &, angle]]}]]

Mathematica graphics

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453

1 Answers1

5

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]}, 
 Panel@Dynamic@
   Column[{Row@{Slider[Dynamic[x], {0, 2 Pi}], 
       Dynamic[{x, ControlActive["a", "Inactive"]}]}, 
     Grid[MapIndexed[
       With[{i = #2[[1]]}, {DynamicModule[{y}, 
           Row@{Slider[Dynamic[y, (angle[[i]] = y = #) &], {0, 2 Pi}],
              Dynamic[{y, ControlActive["Active", "Inactive"]}]}]}] &,
        angle]]}]]
Basheer Algohi
  • 19,917
  • 1
  • 31
  • 78