Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used to program in Visual Basic, but in Mathematica I have not seen some kind of restore default values after any user modification command in the Manipulate environment. For instance, in

Manipulate[x + y, {{x, 1, "First"}, 1, 6}, {{y, 40, "Second"}, {40, 50, 60}}]

enter image description here

The user modify the slider for x to 5.

enter image description here

After that, when the user pick other value for y, there is a way to restore x to the initial value? such that:

enter image description here

And also by modifying the slider x again restore the value y to 40. In other words, by detect a modification in the controllers, could Manipulate restore the default values?

share|improve this question
And then, when one moves the slider, y is set to 40 too? – Kuba Apr 8 '14 at 21:03
You can do this easily using bookmarks – Mike Honeychurch Apr 8 '14 at 21:10
Yeah Kuba, the idea is moving any of these controllers the other must return to its initial condition...holding the new value of the last modified controller. – Jotasmall Apr 8 '14 at 21:35
up vote 2 down vote accepted

I think your requirement is not correct for the user. What should display on the screen should match the current x+y value based on what is currently selected for x and y and not what was there before.

If you keep the old value displayed, then the new selection do not match what is on the screen and that can be confusing.

But I made two versions, and you pick the one you think fits for your need. It is easy to make many combinations of this, feel free to change as needed. all what you have to do is change the logic in the second argument of dynamic for the control. The idea is to use the second argument of dynamics and use that as callback event and add the logic there to do any changes needed before the display is shown.

version 1

    Manipulator[Dynamic[x, {x = #; value = x + y} &], {1, 6, 0.1}, 
     ImageSize -> Tiny, ContinuousAction -> True],Dynamic[NumberForm[x, {3, 2}]]
   {SetterBar[Dynamic[y, {y = #; x = 1} &], {40, 50, 60}], SpanFromLeft}
   }, Alignment -> Left],
 {{x, 1}, None},
 {{y, 40}, None},
 {{value, 1 + 40}, None}

second version

 x + y, 
 Grid[{{"First", Manipulator[Dynamic[x, {x = #; y = 40} &], {1, 6, 0.1}, 
    ImageSize -> Tiny, ContinuousAction -> True], Dynamic[NumberForm[x, {3, 2}]]
   SetterBar[Dynamic[y, {y = #; x = 1;} &], {40, 50, 60}], SpanFromLeft}}, 
   Alignment -> Left
   {{x, 1}, None}, 
   {{y, 40}, None}]

enter image description here

share|improve this answer
Ok! Nasser, I will take the second version...could you please explain me how works tick in the line of the manipulator? – Jotasmall Apr 9 '14 at 0:21
I removed that. Not needed actually here. Updated the code. – Nasser Apr 9 '14 at 2:24

Use bookmarks to return to your initial settings or to any other bookmarked settings.

enter image description here

share|improve this answer
I know about this option, but it will erase the new value for the recently modified controller! That's no the idea... – Jotasmall Apr 8 '14 at 21:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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