2

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"}
 ]

enter image description here

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]
 ]

enter image description here

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]

 ]

enter image description here

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,

Community
  • 1
  • 1
Nasser
  • 12,849
  • 6
  • 52
  • 104

2 Answers2

3

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]]

made using the above

Simon
  • 14,631
  • 4
  • 41
  • 101
  • Simon for the rescue again! Great. I just never thought of trying Manipulator. I only used Manipulator once, long time ago, did not think of it. Thanks again. btw, the demo is now working very well, using the second argument of Dynamics really made a big difference in simplifying the logic. I think the second argument of Dynamic is the most well kept secret in Mathematica. – Nasser Sep 07 '11 at 22:34
  • 2
    secret? It is well documented here:http://reference.wolfram.com/mathematica/ref/Dynamic.html and the first of the "Neat Examples" makes things clear. Too bad we can not ask for a hit-lists of secrets here ( e.g. Alt-Click on a cell, is this now somehere documented? Or how to efficiently debug? Or write documentation?) – Rolf Mertig Sep 07 '11 at 22:42
  • @Rolf: Never knew about the (Ctrl)-Alt-Click thing! There's been a couple of questions on debugging and a few on writing documentation, maybe the best of them should be added to the [Mathematica toolbag](http://stackoverflow.com/q/4198961/421225) community wiki. – Simon Sep 07 '11 at 22:59
  • @Simon, what does ALT-CTRL-CLICK supposed to do? It does nothing on my V8.0.1 on windows 7. Not on the cell boundary and not on the cell inside. – Nasser Sep 08 '11 at 03:34
  • @Rolf. ALT-CLICK does nothing also. ps. the part about' secret' feature of second argument of dynamic was just a tongue-in-cheek remark on me, because it had a feature I needed and struggled to find for long time and did not know about it, which is an "easy" way to know when a specific Manipulate control variable changed. Thanks. – Nasser Sep 08 '11 at 03:40
  • ops, I meant to say CTRL-ALT-CLICK above, not ALT-CTRL-CLICK. I tried both, and they do nothing on my V 8.0.1 – Nasser Sep 08 '11 at 04:09
  • @Nasser: On Windows it is probably Alt-Click, like Rolf said. (On linux Alt-Click is reserved, so it's remapped to Ctrl-Alt-Click). Do it on a cell bracket and it selects all cells of that type. – Simon Sep 08 '11 at 04:13
0

Or Control:

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

control

Rolf Mertig
  • 1,360
  • 8
  • 22
  • Thanks for your answer. But I must be missing something. The idea is to NOT use Control[] or standard Manipulate {} control, since these constructs do not provide a way to insert the second argument of Dynamic in them. Needed to use Dynamic directly to set up the control variable to allow the use of the second argument. Thanks. – Nasser Sep 08 '11 at 04:30