Button Component - Maple Help

DocumentTools[Components]

 Button
 generate XML for a Button Component

 Calling Sequence Button( caption, opts )

Parameters

 caption - (optional) string:="Button"; the caption on the button opts - (optional) ; one or more keyword options as described below

Options

 • action : string:=""; A string which parses to one or more valid statements in 1-D Maple Notation. These statements form the Value Changed Action Component Code that executes when the Button is clicked. The default is the empty string (no action code).
 • enabled : truefalse; Indicates whether the component is enabled. The default is true. If enabled is false then the inserted component is grayed out and interaction with it cannot be initiated.
 • fontcolor : {list(nonnegint),symbol,string}:=[0,0,0] ; Specifies the font color of the component. The passed value can be either a named color or a list of three integers each between 0 and 255. A list of nonnegative integers is interpreted as RGB values in a 24bit 3-channel color space. The default value is [0,0,0] which corresponds to black.
 • height : posint; The height in pixels of the component. Only affects the component if an image is being used.
 • identity : {name,string}; The reference name of the component.
 • image : {string,Matrix,Array}; Image to be displayed on the component, specified as either the name of an external image file or a Matrix or Array as recognized by commands in the ImageTools package. The caption option and the image option are mutually exclusive; only one can be supplied.
 • showborders : truefalse; Indicates whether borders will be shown
 • tooltip : string; The text that appears when the mouse pointer hovers over the component. The default is the empty string (no tooltip).
 • visible : truefalse; Indicates whether the component is visible. The default is true.
 • width : posint; The width in pixels of the component. Only affects the component if an image is being used.

Description

 • The Button command in the Component Constructors package returns an XML function call which represents a Button Component.
 • The generated XML can be used with the results of commands in the Layout Constructors package to create an entire Worksheet or Document in XML form. Such a representation of a Worksheet or Document can be inserted into the current document using the InsertContent command.

Examples

 > $\mathrm{with}\left(\mathrm{DocumentTools}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Components}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Layout}\right):$

Executing the Button command produces a function call.

 > $S≔\mathrm{Button}\left("My Button",\mathrm{identity}="Button0"\right)$
 ${S}{≔}{\mathrm{_XML_EC-Button}}{}\left({"id"}{=}{"Button0"}{,}{"caption"}{=}{"My Button"}{,}{"enabled"}{=}{"true"}{,}{"fontcolor"}{=}{"\left[0,0,0\right]"}{,}{"visible"}{=}{"true"}{,}{"show-border"}{=}{"true"}\right)$ (1)

By using commands from the Layout Constructors package a nested function call can be produced which represents a worksheet.

 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right):$

That XML representation of a worksheet can be inserted directly.

 > $\mathrm{InsertContent}\left(\mathrm{xml}\right):$

 > $\mathrm{codestring}≔"\ns := true;\n\nt := false;"$
 ${\mathrm{codestring}}{≔}{"s := true; t := false;"}$ (2)
 > $S≔\mathrm{Button}\left("My Button",\mathrm{identity}="Button0",\mathrm{tooltip}="My example button",\mathrm{action}=\mathrm{codestring}\right):$
 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right):$

The previous example's call to the InsertContent command inserted a component with identity "Button0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "Button0" incurs a substitution of the input identity in order to avoid a conflict with the identity of the existing component.

The return value of the following call to InsertContent is a table which can be used to reference the substituted identity of the inserted component.

 > $\mathrm{lookup}≔\mathrm{InsertContent}\left(\mathrm{xml},\mathrm{output}=\mathrm{table}\right)$
 ${\mathrm{lookup}}{≔}{table}{}\left(\left[{"Button0"}{=}{"Button1"}\right]\right)$ (3)

 > $\mathrm{lookup}\left["Button0"\right]$
 ${"Button1"}$ (4)
 > $\mathrm{GetProperty}\left(\mathrm{lookup}\left["Button0"\right],\mathrm{caption}\right)$
 ${"My Button"}$ (5)
 > $\mathrm{img}≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/images/up_arrow.gif"\right):$
 > $B≔\mathrm{Button}\left(\mathrm{image}=\mathrm{img},\mathrm{identity}="Button17"\right):$
 > $\mathrm{InsertContent}\left(\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(B\right)\right)\right)\right)\right):$

 > $\mathrm{img}≔\mathrm{Array}\left(1..60,1..40,1..3,\left(i,j,k\right)↦\mathrm{if}\left(k=3,\frac{j}{40},0\right),\mathrm{datatype}=\mathrm{float}\left[8\right],\mathrm{order}=\mathrm{C_order}\right):$
 > $B≔\mathrm{Button}\left(\mathrm{image}=\mathrm{img},\mathrm{identity}="Button17"\right):$
 > $\mathrm{InsertContent}\left(\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(B\right)\right)\right)\right)\right):$

 > $B≔\mathrm{Button}\left(\mathrm{image}=\mathrm{img},\mathrm{identity}="Button17",\mathrm{width}=70,\mathrm{height}=20\right):$
 > $\mathrm{InsertContent}\left(\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(B\right)\right)\right)\right)\right):$

 > $B≔\mathrm{Button}\left("My Button",\mathrm{fontcolor}="DarkGreen"\right):$
 > $\mathrm{InsertContent}\left(\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(B\right)\right)\right)\right)\right):$

Compatibility

 • The DocumentTools:-Components:-Button command was introduced in Maple 2015.