1
$\begingroup$

How do I fix the bad behavior of Manipulator? This is in regards to this Interdependent controls in Manipulate question. Heike' s code does not work right on the first click when specifying the Manipulator increment and using Appearance -> "Open" for both Manipulators. For instance, a first click on "Step Forward" does not produce the increment x +=.1. Also, closing y, then incrementing x looks okay until you open y. This bad behavior only occurs on the first click after evaluating the cell, but a solution should be found. Here is the code:

 Manipulate[{x, y},
  {x, Manipulator[Dynamic[x, (x = #; y = 1/#) &],
      {.1, 10, .1}, Appearance -> "Open"] &},
  {y, Manipulator[Dynamic[y, (y = #; x = 1/#) &],
      {.1, 10, .2}, Appearance -> "Open"] &},
  Initialization :> ({x, y} = {1, 1})]

The error persists no matter what is done. This simple version without Dynamic does not increment by .1 on the first click on x+ or y+.

   Manipulate[
   If[xh != x, xh = x; y = 1/x; yh = y];
   If[yh != y, yh = y; x = 1/y; xh = x];

   {x, y},
   {{x, x0, "x: "}, .1, 10, .1, Appearance -> "Open"},
   {{y, y0, "y: "}, .1, 10, .1, Appearance -> "Open"},
   Initialization :> {xh = x = x0 = 1; yh = y = y0 = 1/x;},
   TrackedSymbols :> {x, y}]
$\endgroup$
3
$\begingroup$

Suggest you use DynamicModule for want you are trying. Like so.

DynamicModule[{x = 1, y = 1},
 Column @
  {Dynamic @ {x, y},
   Manipulator[Dynamic[x, (x = #; y = 1/#)&], {.1, 10, .1}, Appearance -> "Open"], 
   Manipulator[Dynamic[y, (y = #; x = 1/#)&], {.1, 10, .2}, Appearance -> "Open"]}]

demo

IMO easier than Manipulate in this case. But if your heart is set on using Manipulate, then

Manipulate[
  {x, y},
  {x,
   Manipulator[
     Dynamic[#, (x = #; y = 1/#)&], {.1, 10, .1}, Appearance -> "Open"]&}, 
  {y, 
   Manipulator[
     Dynamic[#, (y = #; x = 1/#)&], {.1, 10, .2}, Appearance -> "Open"]&}, 
   Initialization :> ({x, y} = {1, 1})]

manip

$\endgroup$

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.