Radio Button Component - Maple Help

Home : Support : Online Help : Programming : Document Tools : Components : Radio Button Component

DocumentTools[Components]

 generate XML for a RadioButton Component

Parameters

 caption - (optional) string:="RadioButton"; the caption on the radio 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 RadioButton value is manually adjusted. 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.
 • fillcolor : {list(nonnegint),symbol,string}:=[255,255,255] ; Specifies the background 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 [255,255,255] which corresponds to white.
 • 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.
 • group : string:=""; The name of the group with which this component is associated. The default is the empty string (no group).
 • identity : {name,string}; The reference name of the component.
 • selected : truefalse; Indicates whether the component is initially selected (checked). The default is false (unchecked).
 • 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.

Description

 • The RadioButton command in the Component Constructors package returns an XML function call which represents a RadioButton 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 RadioButton command produces a function call.

 > $S≔\mathrm{RadioButton}\left(\mathrm{identity}="RadioButton0"\right)$
 ${S}{≔}{\mathrm{_XML_EC-RadioButton}}{}\left({"id"}{=}{"RadioButton0"}{,}{"caption"}{=}{"RadioButton"}{,}{"selected"}{=}{"false"}{,}{"groupname"}{=}{""}{,}{"enabled"}{=}{"true"}{,}{"fillcolor"}{=}{"\left[255,255,255\right]"}{,}{"fontcolor"}{=}{"\left[0,0,0\right]"}{,}{"visible"}{=}{"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):$

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

In the next example, all three button's identities can be replaced by substitution, as a chain of consequences. The first button with caption "A" has its identity replaced to avoid a conflict with the button inserted in the previous example. The second button with caption "B" can have its identity replaced to avoid a conflict with the new, substituted identity of button "A". Button "C" can have its identity replaced to avoid a conflict with the new, substituted identity of button "B".

 > $\mathrm{S1}≔\mathrm{RadioButton}\left("A",\mathrm{identity}="RadioButton0",\mathrm{selected},\mathrm{group}="mygroup"\right):$
 > $\mathrm{S2}≔\mathrm{RadioButton}\left("B",\mathrm{identity}="RadioButton1",\mathrm{group}="mygroup"\right):$
 > $\mathrm{S3}≔\mathrm{RadioButton}\left("C",\mathrm{identity}="RadioButton2",\mathrm{group}="mygroup"\right):$
 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(\mathrm{S1},\mathrm{S2},\mathrm{S3}\right)\right)\right)\right):$

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

 > $\mathrm{lookup}≔\mathrm{InsertContent}\left(\mathrm{xml},\mathrm{output}=\mathrm{table}\right)$
 ${\mathrm{lookup}}{≔}{table}{}\left(\left[{"RadioButton2"}{=}{"RadioButton3"}{,}{"RadioButton0"}{=}{"RadioButton1"}{,}{"RadioButton1"}{=}{"RadioButton2"}\right]\right)$ (2)

 > $\mathrm{seq}\left(\mathrm{lookup}\left[b\right],b=\left["RadioButton0","RadioButton1","RadioButton2"\right]\right)$
 ${"RadioButton1"}{,}{"RadioButton2"}{,}{"RadioButton3"}$ (3)
 > $\mathrm{seq}\left(\mathrm{GetProperty}\left(\mathrm{lookup}\left[b\right],\mathrm{value}\right),b=\left["RadioButton0","RadioButton1","RadioButton2"\right]\right)$
 ${"true"}{,}{"false"}{,}{"false"}$ (4)

The next example makes use of action code for a pair of grouped radio buttons. When either radio button is manually selected the respective action code is executed.

The action code updates a PlotComponent with identity "Plot0", which will be an additional part of the inserted content. This component will be constructed using the Plot Component constructor.

 > $p≔\mathrm{plot}\left(\mathrm{sin}\left(x\right),x=-2\mathrm{\pi }..2\mathrm{\pi }\right):$
 > $P≔\mathrm{Components}:-\mathrm{Plot}\left(p,\mathrm{identity}="Plot0"\right):$

Each action code consists of multi-line statements supplied as a string.

 > $\mathrm{actioncode}\left["c"\right]≔"DocumentTools:-SetProperty\left(\text{'}:-Plot0\text{'},value,\n plots:-display\left(p,scaling=constrained\right)\right);":$
 > $\mathrm{actioncode}\left["u"\right]≔"DocumentTools:-SetProperty\left(\text{'}:-Plot0\text{'},value,\n plots:-display\left(p,scaling=unconstrained\right)\right);":$
 > $\mathrm{S1}≔\mathrm{RadioButton}\left("constrained",\mathrm{identity}="RB0",\mathrm{group}="newgroup",\mathrm{action}=\mathrm{actioncode}\left["c"\right]\right):$
 > $\mathrm{S2}≔\mathrm{RadioButton}\left("unconstrained",\mathrm{identity}="RB1",\mathrm{selected},\mathrm{group}="newgroup",\mathrm{action}=\mathrm{actioncode}\left["u"\right]\right):$
 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(P\right)\right)\right),\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(\mathrm{S1},\mathrm{S2}\right)\right)\right)\right):$

Following insertion either radio button can be manually selected, which causes the respective action code to execute and the "Plot0" component to be updated.

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

 > $\mathrm{S1}≔\mathrm{RadioButton}\left("constrained",\mathrm{identity}="RB0",\mathrm{group}="newgroup",\mathrm{action}=\mathrm{actioncode}\left["c"\right],\mathrm{fillcolor}="LightBlue",\mathrm{fontcolor}="Blue"\right):$$\mathrm{S2}≔\mathrm{RadioButton}\left("unconstrained",\mathrm{identity}="RB1",\mathrm{selected},\mathrm{group}="newgroup",\mathrm{action}=\mathrm{actioncode}\left["u"\right],\mathrm{fillcolor}="LightBlue",\mathrm{fontcolor}="Blue"\right):$$\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Table}\left(\mathrm{interior}=\mathrm{none},\mathrm{width}=500,\mathrm{widthmode}=\mathrm{pixels},\mathrm{Column}\left(\right),\mathrm{Row}\left(\mathrm{Cell}\left(\mathrm{Textfield}\left(P\right),\mathrm{fillcolor}="LightBlue"\right)\right),\mathrm{Row}\left(\mathrm{Cell}\left(\mathrm{Textfield}\left(\mathrm{S1},\mathrm{S2}\right),\mathrm{fillcolor}="LightBlue"\right)\right)\right)\right):$
 > $\mathrm{InsertContent}\left(\mathrm{xml}\right):$

 > 

Compatibility

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