Creating a Button

There are three ways to create a button: through a kernel function, through direct box input, or through a specialized menu command.

Direct Box Input

The Mathematica notebook front end provides a dialog box for entering low­level box structures.  It can be summoned with  the front end menu command Edit -> Expression Input -> Insert Raw Expression... or with the keystroke shortcut Ctrl[*].

When the user dismisses the dialog box with the Insert button, the front end will place the box data input wherever the text cursor resides.  If a horizontal cell insertion point is present in the notebook, a new cell with the notebook's default cell style will be created.

Specialized Front End Menu Command

The front end also provides the menu command Input -> Create Button, which is useful for creating active elements with predefined attributes.  We will discuss this feature in greater depth once we are more familiar with the details of tuning buttons.

Kernel­based Expression Formatting

The kernel function DisplayForm can be used to generate a button from its raw typeset form.

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

A ButtonBox expression created this way will always appear within a two­dimensional typeset environment.

Of the approaches discussed here, this is probably the most useful for the purposes of prototyping more complicated buttons.  The other methods are less forgiving, meaning that you can lose your work by supplying incorrect input.



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: