How to add element 'Show Animation Control' directly (not using Manipulate control setting)?

寵の児 提交于 2019-12-13 17:00:17

问题


I am not able to find how to do the following. When using Manipulate, it automatically shows a little '+' at the end of the control, as the following

Manipulate[x,
 {{x, 0, "x"}, 0, 1, .1, Appearance -> "Labeled"}
 ]

Now, I want to set up the control directly myself using Dynamic, and make it look just like the above, like this: (Btw, thanks to Simon for showing the correct syntax to do this here

Manipulate[x,
 {{xChanged, False}, None},

 Grid[{
   {"x ", 
    Slider[Dynamic[x, (x = #; xChanged = True; #) &], {0, 1, .1}], 
    Spacer[2],
    Dynamic@x
    }
   }, Frame -> None, Spacings -> {0.2, 0.1}, Alignment -> Center]
 ]

Now, the only thing missing is the little '+'. I can't use the AppearanceElement options on the above. So, next I tried this

Manipulate[x,
 {{xChanged, False}, None},

 Grid[{
   {"x ", 
    Animator[Dynamic[x, (x = #; xChanged = True; #) &], {0, 1, .1}, 
     AnimationRunning -> False], Spacer[2],
    Dynamic@x
    }
   }, Frame -> None, Spacings -> {0.2, 0.1}, Alignment -> Center]

 ]

But that gives too many. I only need the '+' which is labeled 'Show animation controls' when using Manipulate. But I can't find the element which matches this one.

It is strange that it is so hard to find the names of these elements. I go to ref/AppearanceElements and it does not even list the names. When I go to ref/Manipulate it mentions the following ones under Appearance Elements option {"HideControlsButton", "SnapshotButton", "ResetButton", "UpdateButton" and I tried them all, but they are not what I want.

I went to ref/Manipulator, and saw these "InputField", "StepLeftButton", "PlayPauseButton", "StepRightButton", "FasterSlowerButtons", "DirectionButton", "InlineInputField". But none of them is the 'Show animation controls' one.

Does any one know how to get '+' element?

(strange that these elements are not all be listed in one place, in ref/AppearanceElements )

Thank you,


回答1:


Is there any reason that you can't use a Manipulator?

Manipulate[x, {{xChanged, False}, None}, {x, None}, 
 Grid[{{"x ", 
    Manipulator[
     Dynamic[x, (x = #; xChanged = True; #) &], {0, 1, .1}], 
    Spacer[2], Dynamic@x}}, Frame -> None, Spacings -> {0.2, 0.1}, 
  Alignment -> Center]]




回答2:


Or Control:

Manipulate[x,  
   Grid[{{"test: ", Control[{x, 0, 1}], Spacer[9], Dynamic[x]}}, 
  Spacings -> {0.2, 0.1}]]



来源:https://stackoverflow.com/questions/7340971/how-to-add-element-show-animation-control-directly-not-using-manipulate-cont

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!