6
$\begingroup$

I want to hide over's control if len is higher than 15.

ControlType -> None

isn't doing what I want. Why?

Manipulate[len, {len, 10, 20, 1, Appearance -> "Labeled"},

 {over, 0, 30,  1, Appearance -> "Labeled", 
  ControlType -> If[len  > 15, None, Slider]}]
$\endgroup$
7
$\begingroup$

This is a simpler version. I keep the older version below for reference.

enter image description here

Manipulate[{len, over},

 Dynamic[If[len > 15,

   Control[{{len, 10, "len"}, 10, 20, 1, Appearance -> "Labeled", Slider}],

   Grid[{
     {Control[{{len, 10, "len"}, 10, 20, 1, Appearance -> "Labeled",Slider}]},
     {Control[{{over, 10, "over"}, 0, 30, 1, Appearance -> "Labeled", Slider}]}
     }
    ]
   ]
  ]
 ]

Old answer

enter image description here

Manipulate[{len, over},

 Grid[{
   {Text@"Len", Manipulator[Dynamic[len, {len = #} &], {10, 20, 1}], 
    Dynamic@len},

   {Dynamic@If[len > 15,
      Invisible@
       Row[{Text@"over", Manipulator[Dynamic[over, {over = #} &], {0, 30, 1}], over}],

      Row[{Text@"over", Manipulator[Dynamic[over, {over = #} &], {0, 30, 1}], over}]
      ], SpanFromLeft
    }
   }, Spacings -> {1, 1}
  ],

 {{len, 10}, None},
 {{over, 10}, None}
 ]
| improve this answer | |
$\endgroup$
4
$\begingroup$

I prefer Nasser's original answer because I don't like a manipulate panel that changes size every time the 'over' slider disappears and reappears. However, I would suggest the following simplification to its code.

Manipulate[
  Row[{"length ", length, "  over ", over}],
  Dynamic @ Column[
    {Control[{{length, 10}, 10, 20, 1, AppearanceElements -> All}],
     If[length > 15, Invisible, Identity] @
       Control[{{over, 15}, 0, 30, 1, AppearanceElements -> All}]}]]

under

over

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