I want to distribute a .cdf to my students wherein they manipulate 5 locators on a graph to define various shapes. The .cdf opens with the locators in a "nice" position, but of course it is very hard to return the locators, by hand, to these positions once they have been moved. Is there a way to utilize a "Reset" button that returns all settings to the original state? The only method I can see right now is to reopen the file in the CDFPlayer.
2 Answers
Your average Manipulate
has the "Inital settings" button (which is just another bookmark):
Another straightforward way would be a simple button to set certain values:
Manipulate[x, {{x, 5}, 0, 10}, Button["Reset", x = 5]]
which (as pointed out in the comments) allows for unlimited styling, for good or bad:
Manipulate[x, {{x, 5}, 0, 10},
Button[Graphics[{EdgeForm[Directive[Thick, Black]], Red, Disk[],
Yellow, Style[Text["Don´t\n PANIC!", {0, 0}], Bold, 40]}],
x = 5, Background -> None]]
-
$\begingroup$ I use the reset button method. More clear and you have more control on what to do there. Also for demo published at WRI web site, those options given in the menu above are not there. Only autorun is there. $\endgroup$– NasserAug 29, 2013 at 13:07
-
$\begingroup$ I, too, like the Reset button better, as it is much more clear to the user. The built in
ResetButton
option also works, but isn't as clear as a big button that says "Reset." $\endgroup$– GregHAug 29, 2013 at 13:11 -
$\begingroup$ @Nasser o.k. - I only tried with the CDF preview, which shows all elements. And yes, the
Button
method is rather more transparent, even if the bookmarks are very useful in some cases. $\endgroup$ Aug 29, 2013 at 13:12 -
$\begingroup$ @GregH and of course, you can
Style
yourButton
however you wish... $\endgroup$ Aug 29, 2013 at 13:13 -
1$\begingroup$ @Mr.Wizard then this is one +1 I specially cherish :-) $\endgroup$ Aug 30, 2013 at 7:22
Just another way, using built-in functionality ResetButton
:
Manipulate[x, {{x, 5}, 0, 10}, AppearanceElements -> "ResetButton"]
-
-
1$\begingroup$ @Mr.Wizard So this day was a good day :) I'm glad you did. $\endgroup$– Kuba ♦Aug 29, 2013 at 19:43