2
$\begingroup$

I would like to add some buttons next to a slider for higher accuracy movements. For instance I have this slider, which has 1-step, pretty easy to use.

In[2]:= Slider[Dynamic[x], {-5, 5, 1}, Appearance -> "Labeled"]

but if I try something like

Slider[Dynamic[x], {-100, 100, 0.001}, Appearance -> "Labeled"]

it is quit difficult to set x's value the precise one I want. Hence it would be helpful to add some arrow buttons that will be click and step.

Does anyone know if there is such an ability?

Furthermore it is crucial to have Dynamic[x] so that x is set in real time.

Thanks

$\endgroup$
2
  • 5
    $\begingroup$ pressing Alt while dragging makes it more precise, with Alt+Shift even more. $\endgroup$
    – Kuba
    Jan 21 '16 at 11:14
  • 1
    $\begingroup$ Additionally, if you know the value of x that you desire, you can Show Animation Controls by clicking the tiny box at the end of the slider and typing that value (followed by <Enter>) into the box. $\endgroup$
    – bbgodfrey
    Jan 21 '16 at 11:51
4
$\begingroup$

You can specify exactly what you want using controls. Have a look at the Introduction to Control Objects tutorial.

Manipulate[x,
 Row[{
   Slider[Dynamic@x, {-100, 100, 0.001}],
   Button["\[LessLess]", x = Max[x - 0.01, -100]],
   Button["<", x = Max[x - 0.001, -100]],
   Button[">", x = Min[x + 0.001, 100]],
   Button["\[GreaterGreater]", x = Min[x + 0.01, 100]]
   }]
 ]

enter image description here

Hope this helps.

$\endgroup$
1
  • $\begingroup$ This is exactly what I wanted, thank you for your help, I appreciate it. $\endgroup$
    – Fierce82
    Jan 22 '16 at 10:16
3
$\begingroup$

Code:

Manipulate[
 x,
 {{x, 0, "X:"}, -100, 100, 0.001}
 ]

Output:

output

Reference:

Manipulate

Tutorial:

Introduction to Manipulate

$\endgroup$
2
  • $\begingroup$ thank you very much, works as I wanted to. Nevertheless, how will I set x to each value? Dynamic[x] does not work.. Manipulate[Dynamic[x], {{x, 0, "X:"}, -100, 100, 0.001}] $\endgroup$
    – Fierce82
    Jan 21 '16 at 11:56
  • 1
    $\begingroup$ @Vasilis glad it helped, if you're satisfied with the answer I would appreciate if you would tick it as accepted answer :P $\endgroup$ Jan 21 '16 at 11:57

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.