TemplateBox

TemplateBox[{box1,box2,},tag]

is a low-level box structure that parameterizes the display and evaluation of the boxes boxi.

TemplateBox["key1"expr1,"key2"expr2,,tag]

allows the use of arbitrary expressions that may or may not be boxes.

Details and Options

Examples

open allclose all

Basic Examples  (3)

Display a template that is stored in the style "Binomial" in a stylesheet:

Display a template with an explicit DisplayFunction:

Use a template argument as a dynamic value to a Slider:

Scope  (1)

Use InterpretationFunction to control how a template evaluates:

Generalizations & Extensions  (1)

A value that is not in a box form can be used as part of an interpretation with InterpretationBox:

Options  (11)

BaseStyle  (1)

Set the base style of a template:

CopyFunction  (1)

Set a copy form different from the displayed or interpreted form:

Here is the pasted form:

fowl

DisplayFunction  (1)

DisplayFunction overrides any DisplayFunction inherited from the stylesheet:

Editable  (1)

The contents of a TemplateBox are editable by default:

SelectableFalse will make it impossible to edit any individual argument of the box:

InterpretationFunction  (2)

The InterpretationFunction yields a box structure that will be used for evaluation:

This same structure used as input evaluates to LieBracket:

A value of Automatic causes tag to be used as the function head of the box structure:

Selectable  (1)

The contents of a TemplateBox are selectable by default:

SelectableFalse will make it impossible to select any individual argument of the box:

SyntaxForm  (1)

SyntaxForm can be used to set the precedence of a TemplateBox used as an operator:

Tooltip  (1)

Specify the tooltip that will be displayed when the mouse hovers over a template box:

Tooltip->Automatic generates a tooltip from tag:

TooltipDelay  (1)

Set a tooltip with a two-second delay:

TooltipStyle  (1)

Change the tooltip background color and font size:

Possible Issues  (2)

A DisplayFunction resulting in an invalid box structure can produce an error:

A template parameter cannot be used as both an editable field and a dynamic value:

While the preceding initially displays correctly, attempts to edit it do not update the dynamic values:

Use an InputFieldBox to create an editable field that is also a dynamic value:

Neat Examples  (1)

Create a box that displays as a popup menu and evaluates as the selected value:

Evaluating the box as an input returns the selected value:

Wolfram Research (2008), TemplateBox, Wolfram Language function, https://reference.wolfram.com/language/ref/TemplateBox.html (updated 2020).

Text

Wolfram Research (2008), TemplateBox, Wolfram Language function, https://reference.wolfram.com/language/ref/TemplateBox.html (updated 2020).

CMS

Wolfram Language. 2008. "TemplateBox." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/TemplateBox.html.

APA

Wolfram Language. (2008). TemplateBox. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TemplateBox.html

BibTeX

@misc{reference.wolfram_2024_templatebox, author="Wolfram Research", title="{TemplateBox}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/TemplateBox.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_templatebox, organization={Wolfram Research}, title={TemplateBox}, year={2020}, url={https://reference.wolfram.com/language/ref/TemplateBox.html}, note=[Accessed: 22-December-2024 ]}