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
- Follow-Ups:
- Re: Re: Buttons to close and open cells at certain
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: Buttons to close and open cells at certain
- References:
- Buttons to close and open cells at certain levels?
- From: AES <siegman@stanford.edu>
- Buttons to close and open cells at certain levels?