I have discovered a problem with OpenerView. My opener views always close when I change the value of the manipulator control in my Manipulate.

A simple example:

   {OpenerView[{"plot1", Panel@Plot[x^2, {x, -10, 2}]}, False], 
    OpenerView[{"plot2", Panel@Plot[x^2 + 3 x, {x, -10, 2}]}, False], 
    Plot3D[Sin[ n x y], {x, -2, 2}, {y, -2, 2}]}],
 {n, 1, 10, 1}]

enter image description here

I tried the option ContentSize in the Manipulate and ImageSize in the OpenerView, but both failed.

My question is what options do I need to add to make the interface to keep the state of the opener views unchanged when I change the value of the slider for n?


As long as the opener views are part of the first argument of a Manipulate, they will be evaluated every time the Manipulator control for n is evaluated. This means openers will always either close or open (depending on the value of their optional second argument) when the slider is moved. This will be true even if they are wrapped in a Refresh[..., None] expresion.

The only solution I can see is to take the opener views out of the first argument (i,e., the content pane) and make them annotations.

   Plot3D[Sin[n x y], {x, -2, 2}, {y, -2, 2}],
   {n, 1, 10, 1, ImageSize -> Large},
   OpenerView[{"plot1", Panel @ Plot[x^2, {x, -10, 2}]}], 
   OpenerView[{"plot2", Panel @ Plot[x^2 + 3 x, {x, -10, 2}]}]]

This will change the look of your GUI, but only a little. It will work for your example because it has no dynamic content. Annotations permit dynamic content, but managing such content would mean a little more work.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy