12
$\begingroup$

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.

$\endgroup$

2 Answers 2

17
$\begingroup$

Your average Manipulate has the "Inital settings" button (which is just another bookmark):

Mathematica graphics

Another straightforward way would be a simple button to set certain values:

Manipulate[x, {{x, 5}, 0, 10}, Button["Reset", x = 5]]

Mathematica graphics

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

Mathematica graphics

$\endgroup$
6
  • $\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$
    – Nasser
    Aug 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$
    – GregH
    Aug 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$
    – Yves Klett
    Aug 29, 2013 at 13:12
  • $\begingroup$ @GregH and of course, you can Style your Button however you wish... $\endgroup$
    – Yves Klett
    Aug 29, 2013 at 13:13
  • 1
    $\begingroup$ @Mr.Wizard then this is one +1 I specially cherish :-) $\endgroup$
    – Yves Klett
    Aug 30, 2013 at 7:22
15
$\begingroup$

Just another way, using built-in functionality ResetButton:

Manipulate[x, {{x, 5}, 0, 10}, AppearanceElements -> "ResetButton"]

enter image description here

$\endgroup$
2
  • $\begingroup$ I just learned something. +1 $\endgroup$
    – Mr.Wizard
    Aug 29, 2013 at 19:35
  • 1
    $\begingroup$ @Mr.Wizard So this day was a good day :) I'm glad you did. $\endgroup$
    – Kuba
    Aug 29, 2013 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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