MathGroup Archive 2007

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

Search the Archive

Re: Button on a palette to create new text cells

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77998] Re: Button on a palette to create new text cells
  • From: David Reiss <dbreiss at gmail.com>
  • Date: Thu, 21 Jun 2007 05:39:50 -0400 (EDT)
  • References: <f5au9h$bll$1@smc.vnet.net>

Here is an example that perhaps you can use as a starting point for
experimentation:

CreatePalette[
 Button["New Text Cell", With[{nb = InputNotebook[]},
   SelectionMove[nb, Below, Cell];
   NotebookWrite[nb,
    Cell["", "Text", Background -> Red, FontFamily -> "Helvetica"]]
   ],
  Appearance -> "Palette",
  BaseStyle -> {11, "Helvetica"}
  ]
 ]

The FrontEndTokens are useful, but they are very limited.  Generally
the right way to go if you want to do some pretty advanced things is
to use FrontEnd programming techiques.

Of course this is the sort of thing that goes on behind the scenes in
droves in A WrokLife FrameWork http://scientificarts.com/worklife

I hope that this helps,

David




On Jun 20, 6:07 am, Donald DuBois <don... at comcast.net> wrote:
> I am trying to create a palette that has a button
> on it which, when clicked, will create a new text cell
> right under the cursor in the selected notebook and this cell will have a given background color, font family and font size.   The closest I have
> been able to get to this goal are the following
> lines:
>
> CreatePalette[
>  {
>
>   Button["New Txt Cell", FrontEndExecute[FrontEndToken[SelectedNotebook[], "SimilarCellBelow"]]]
>
>   }
>  ]
>
> This creates a new cell which I hoped to be able to modify to
> be of Style "Text" with a given background color, font family and size but have not been able to do so.
> The style stays the same as the previous cell - whatever that may have been - and I don't seem to be able to change that.
>
> There is no token other than "SimilarCellBelow" that I have found that seems capable of generating a new cell
> which is why I am trying to modify what it does.
>
> The general application is to be able to easily add text cells for comments in a notebook without having to select the cell, and go to the Format pull down menu
> and then click on a style.
>
> Any suggestions would be creatly appreciated.
>
> Don




  • Prev by Date: re: Same Limit in v5.2 and v6.0 - conclusion, I hope...
  • Next by Date: Re: Integrate modified in version 6?
  • Previous by thread: RE: Button on a palette to create new text cells
  • Next by thread: ComplexExpand in Mathematica 5.2 and 6