MathGroup Archive 2004

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

Search the Archive

Clear cell labels palette

  • To: mathgroup at smc.vnet.net
  • Subject: [mg48791] Clear cell labels palette
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Wed, 16 Jun 2004 04:55:41 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

To MathGroup,
In Mathematica Help, on "ButtonBox", among "Further Examples", there is one
example:

"Evaluate the following cell to create the button ?Clear cell labels?. Click
on the button to remove all cell labels from this notebook. "

ButtonBox[StyleBox["Clear cell labels", FontFamily -> "Helvetica"],
    ButtonFunction :>
      FrontEndExecute[{SelectionMove[EvaluationNotebook[], All, Notebook],
          SetOptions[NotebookSelection[EvaluationNotebook[]],
            CellLabel -> ""]}], ButtonEvaluator -> None,
    Active -> True] // DisplayForm

Such a button is convenient if you restart the Kernel. So I evaluated this
to create a button. Then I selected the button, applied "Generate Palette
from Selection" and saved the palette under the directory
$UserBaseDirectory\Applications\Palettes\FrontEnd\Palettes. Then I can
easily load this palette from "Palettes". So long everything worked out OK.

But when I used this palette button it did not work every time. I had to
select the content of a cell or a part of the content of a cell for it to
function. If I only select the notebook or a whole cell in the notebook, or
have the insertion point between two cells, the palette button does not
work. Something with the command SelectionMove[EvaluationNotebook[], All,
Notebook] seems to affect this. (I have Mathematica 5.0.1 on a Windows Me
mashine). If I replace EvaluationNotebook[] with InputNotebook[], the button
works much better. Thus, try to make a palette of

ButtonBox[StyleBox["Clear cell labels", FontFamily -> "Helvetica"],
    ButtonFunction :>
      FrontEndExecute[{SelectionMove[InputNotebook[], All, Notebook],
          SetOptions[NotebookSelection[InputNotebook[]],
            CellLabel -> ""]}], ButtonEvaluator -> None,
    Active -> True] // DisplayForm

and store it in the way outlined before, if you need it.
Can someone explain to me what was wrong with the use of
EvaluationNotebook[] in this button?

Have fun!

Ingolf Dahl
Sweden


  • Prev by Date: Suggestions for more compact code
  • Next by Date: Re: Integral of a bivariate function
  • Previous by thread: Re: Suggestions for more compact code
  • Next by thread: Re: Clear cell labels palette