Typesetting Structure

A ButtonBox delineates a block of styled text that can be clicked with a mouse pointer to perform an action.  It forms the basis of buttons and other classes of active elements.

The syntax for a ButtonBox is:

ButtonBox[contents]

A ButtonBox may appear within cells that contain plain text (TextData) or two­dimensional typeset text (BoxData).  

The following examples illustrate how a ButtonBox may appear within a cell expression and what it looks like on screen.

Here is a cell expression with plain text content.

Cell[
  TextData[{
    "some text with a ",
    ButtonBox["button"],
    " in it"
  }],
  "Text",
  TextAlignment->Center
]

This is what it looks like the cell is formatted by the front end.  It is indistinguishable from the surrounding text.  If you move your mouse pointer over the word "button," the cursor will turn into an arrow as if it were clickable.

[Graphics:../Images/text_button.gif]

Here is a cell expression with two­dimensional typeset content.

Cell[
  BoxData[
    FractionBox[
      "a",
      ButtonBox["b"]
    ]
  ],
  "Text",
  TextAlignment->Center
]

When the box data expression is rendered by the front end, the button appears as a gray box with a raised effect.  When the mouse pointer is moved over the gray region, it does not change appearance.

[Graphics:../Images/Buttons19991022_gr_2.gif]

We will use the term "button" as a synonym for ButtonBox.