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$
0

1 Answer 1

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$
2
  • $\begingroup$ Did you notice that the Initialization :> ({x, y} = {1, 1} does not work corectly in V12, and that the increments don't work correctly in V11.3 on the first click of +. $\endgroup$
    – user48879
    Oct 28, 2019 at 8:43
  • $\begingroup$ @kmutiny. I don't have V12, so I know nothing of the behavior of the Manipulate form in that version. As for what you say about a problem with the increments in V11.3, it is not clear to me what you mean. In any case, as I said in the answer, I don't recommend using a Manipulate form to solve your problem. $\endgroup$
    – m_goldberg
    Oct 28, 2019 at 17:11

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.