Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Buttons to close and open cells at certain levels?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75663] Re: [mg75605] Buttons to close and open cells at certain levels?
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Tue, 8 May 2007 05:49:51 -0400 (EDT)
  • References: <200705060553.BAA03847@smc.vnet.net>

AES wrote:

>I'd love to have a template for a cell I could put at or near the top of 
>many of my notebooks that would have two buttons:  click one button and 
>all cells except cells at Style levels cmd-5 and cmd-6 (and the button 
>cell itself) immediately close; click the other button, they all open 
>back up again.
>
>In other words, a single-click "Collapse to outline form showing section 
>and subsection cells only" and then a single-click re-open capability 
>(and this should operate, incidentally without depending upon or messing 
>around with how any of the Cell Grouping rules are set).  
>
>If any expert Mathematica programmer wants to respond with, "Hey, that's 
>trivial! -- here's how to do it," well, it may not bring you eternal 
>glory, but it'll bring appreciation from me anyway, however long I last 
>as an Mathematica user.
>  
>
If you have version 6, then the following code might do the trick:

SetOptions[InputNotebook[],
  DockedCells ->
  Cell[BoxData[RowBox[{"Outline: ", CheckboxBox[Dynamic[x,
        (nb = InputNotebook[];
          If[#,
           NotebookFind[nb, "Subsubsection", All, CellStyle];
           FrontEndTokenExecute["SelectionCloseAllGroups"];
           SelectionMove[nb, Before, Notebook],
           SelectionMove[nb, All, Notebook];
           FrontEndTokenExecute["SelectionOpenAllGroups"];
           SelectionMove[nb, Before, Notebook]
           ]; x = #) &]]}]]]]

In version 5, similar code should work using ButtonBox, but it won't 
look as nice.

Carl Woll
Wolfram Research


  • Prev by Date: Re: General::obspkg and "Compatibility Guide"???
  • Next by Date: [Mathematica 6] Format->Style sheet->Report. no CELL brackets on the right ! nothing to hold to.
  • Previous by thread: Buttons to close and open cells at certain levels?
  • Next by thread: Re: Re: Buttons to close and open cells at certain