Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to create a button that when I click it it evaluates a cell containing a manipulate code. Also, I would like another button that when I click the output of manipulate disappears.

How can I do it ?

share|improve this question
add comment

1 Answer

The first button you don't have to create ;-) It's called the "Enter" button and it's already on your keyboard. Press it with the insertion cursor in the following block of code:

d = Manipulate[Plot[Sin[k x], {x, 0, 2 \[Pi]}], {k, 1, 10}];
e = True;

Dynamic[If[e, d, ""]]

Mathematica graphics

The second button is generated below. Pressing it toggles the Manipulate between an on and off state.

Button["Manipulate On/Off", e = Not[e]]

Mathematica graphics

share|improve this answer
    
Thanks, it works well in a notebook, but what about use it as a standalone cdf ? It appear doesn't work.... –  maxmc Mar 16 '12 at 19:40
    
Nice, but it evaluates the Manipulate again when you turn it on, as opposed to simply making it disappear and reappear (like if you deleted the manipulate and immediately undid it). –  rm -rf Mar 16 '12 at 19:58
    
R.M it is possible to paste the manipulate box in the Dynamic function (replacing the variable d). As far as I know there is no Visible->False option for a Manipulate; that would have been useful here. Another option would be to have the function in the Manipulate body to be replaced by a Null function depending on the button state. –  Sjoerd C. de Vries Mar 16 '12 at 20:15
2  
@maxmc The manual states about CDF's: "All interactive content must be generated with the Manipulate command and may only use mouse-driven elements, such as Slider, Locator, Checkbox, PopupMenu, etc." So, a button outside a Manipulate won't work in a CDF. –  Sjoerd C. de Vries Mar 16 '12 at 22:31
add comment

Your Answer

 
discard

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.