# Is it possible restore initial values after modify a control in manipulate?

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}}]


The user modify the slider for x to 5.

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

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?

-
And then, when one moves the slider, y is set to 40 too? –  Kuba Apr 8 at 21:03
You can do this easily using bookmarks –  Mike Honeychurch Apr 8 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 at 21:35

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

Manipulate[
value,
Grid[{
{"First",
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

 Manipulate[
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}]


-
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 at 0:21
I removed that. Not needed actually here. Updated the code. –  Nasser Apr 9 at 2:24