1
$\begingroup$

I not sure if the question has been asked or not. I tried to find something similar without success.

I have this small code:

Manipulate[Plot[Sin[a x], {x, 0, 2}], {a, 1, 10}]

The output is ok. when I changed a using the Manipulate controller bar, the output is ok too. But when I used the keyboard to enter value of a and then Enter, I get a duplicate output:

enter image description here

Did I do something wrong to get this output?

Thank you

$\endgroup$
  • 1
    $\begingroup$ I can reproduce that only for Shift+Enter event or numeric keyboard Enter. It always has been a little bit annoying. $\endgroup$ – Kuba Jan 7 '15 at 19:25
  • 2
    $\begingroup$ Very annoying.. $\endgroup$ – Algohi Jan 7 '15 at 19:28
  • 1
    $\begingroup$ Shift+Enter means evaluate the current cell (if it is evaluatable). When you evaluate a Manipulate output, it evaluates to another (instance of a) Manipulate, as well as converting the output cell to an input cell as shown by the In/Out tags in your screen shot. However annoying it is, the behavior is quite consistent with the documented behavior sifht+enter, which must be familiar to any somewhat experienced user. $\endgroup$ – Michael E2 Jan 7 '15 at 21:13
  • 1
    $\begingroup$ Using Enter (Return keyboard button without shift) solves the issue. $\endgroup$ – Algohi Jan 7 '15 at 22:05
  • $\begingroup$ I use Tab myself, but it changes focus and selects the InputField text. $\endgroup$ – Michael E2 Jan 7 '15 at 22:10
2
$\begingroup$

Your code defines the Control to be a Slider by default. Typing into a different device, the InputField, yields a separate computation and separate output cell.

If you'd like to change the Control for input to be an InputField so you can type different values of a without producing different output cells, try this:

Manipulate[Plot[Sin[a x], {x, 0, 2}], {{a, 5}, InputField}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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