3
$\begingroup$

For this simple code {Dynamic@Rotate[Slider[Dynamic@x, {0, 2*Pi}], x], Slider[Dynamic@x, {0, 2*Pi}]} At x=0 the slider has an style like this

However if I drag the second slider a little, the style of the first slider change at the moment it started to rotate, like this

Moreover, the first slider isn't working normally. It's supposed to control its own rotation, but dragging doesn't work. The only way to move is to click on the bar, instead of dragging, which is weird for a slider. Why?

$\endgroup$
  • $\begingroup$ Do you want the second slider to control the rotation of the first slider? And you don't want the first slider to control its own rotation? Then do {Dynamic@Rotate[Slider[Dynamic@y, {0, 2*Pi}], x], Slider[Dynamic@x, {0, 2*Pi}]} $\endgroup$ – ulvi Apr 20 '18 at 5:26
  • $\begingroup$ @ulvi No, the problem is on a slider that controls its own rotation, it doesn't behave as desired $\endgroup$ – t-smart Apr 20 '18 at 6:52
1
$\begingroup$

To get the slider to rotate itself, do this:

{Rotate[Slider[Dynamic@x, {0, 2*Pi}], Dynamic@x], 
 Slider[Dynamic@x, {0, 2*Pi}]}

Of course, once it rotates, the coordinate system for the slider changes. So using the mouse to set the angle is a bit of a pain, as should be expected.

The reason the OP's code fails (with Dynamic outside Rotate), is that every time the slider is moved, a new instance of a slider is created at rotated to the new angle x. The slider the mouse was controlling disappears, and dragging ceases to have an effect.

You can get a consistent control rendering with the following:

{Rotate[Style[Slider[Dynamic@x, {0., 2*Pi}], 
   ControlsRendering -> "Generic"], Dynamic@x], 
 Slider[Dynamic@x, {0., 2*Pi}]}

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ thanks, but I'm still a little confused about how the dynamic being able to function inside rotate $\endgroup$ – t-smart Apr 23 '18 at 12:32
  • $\begingroup$ @t-smart I can not say that the reason is perfectly clear. Basically, parameters that end up in displayed graphics or other displayed output can be wrapped in Dynamic[] and the Front End will handle them and update them dynamically. Parameters that are gobbled up by the kernel and converted into constant output cannot. The Front End does the rotating when it displays the slider. Hence I figured that x must be one of the parameters I can wrap in Dynamic[]. (The "proof" is that it actually worked.) $\endgroup$ – Michael E2 Apr 23 '18 at 12:38
1
$\begingroup$

The Slider used in mathematica seemed to use microsoft's form. It displayed differently on my mac computer. However there is no sideways slider in windows, so the style changes.

| improve this answer | |
$\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.