Combo Box Component - Maple Help

DocumentTools[Components]

 ComboBox
 generate XML for a ComboBox Component

 Calling Sequence ComboBox( L, opts )

Parameters

 L - (optional) list; list of strings. 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 Select Action Component Code that executes when the ComboBox selection is manually adjusted.
 • 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.
 • identity : {name,string}; The reference name of the component.
 • selected : string; The initially selected item. By default no item is selected.
 • tooltip : string; The text that appears when the mouse pointer hovers over the component.
 • visible : truefalse; Indicates whether the component is visible. The default is true.

Description

 • The ComboBox command in the Component Constructors package returns an XML function call which represents a ComboBox 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):$
 > $L≔\left["A","B","C"\right]$
 ${L}{≔}\left[{"A"}{,}{"B"}{,}{"C"}\right]$ (1)

Executing the ComboBox command produces a function call.

 > $S≔\mathrm{ComboBox}\left(L,\mathrm{identity}="ComboBox0"\right)$
 ${S}{≔}{\mathrm{_XML_EC-ComboBox}}{}\left({"id"}{=}{"ComboBox0"}{,}{"enabled"}{=}{"true"}{,}{"fontcolor"}{=}{"\left[0,0,0\right]"}{,}{"visible"}{=}{"true"}{,}{"A,B,C"}\right)$ (2)

By using commands from the DocumentTools:-Layout 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):$

 > $S≔\mathrm{ComboBox}\left(L,\mathrm{identity}="ComboBox0",\mathrm{selected}="B",\mathrm{tooltip}="My example ComboBox"\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 "ComboBox0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "ComboBox0" 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[{"ComboBox0"}{=}{"ComboBox1"}\right]\right)$ (3)

 > $\mathrm{lookup}\left["ComboBox0"\right]$
 ${"ComboBox1"}$ (4)
 > $\mathrm{GetProperty}\left(\mathrm{lookup}\left["ComboBox0"\right],\mathrm{value}\right)$
 ${"B"}$ (5)

The next example makes use of action code for a ComboBox. When the selected item is manually altered the 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{plot3d}\left(x\mathrm{sin}\left(y\right),x=-10..10,y=-2\mathrm{\pi }..2\mathrm{\pi },\mathrm{shading}=\mathrm{zhue}\right):$
 > $P≔\mathrm{Components}:-\mathrm{Plot}\left(p,\mathrm{identity}="Plot0"\right):$

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

 > $\mathrm{actioncode}≔"DocumentTools:-SetProperty\left(\text{'}:-Plot0\text{'},value,\n plot3d\left(x*sin\left(y\right), x=-10..10, y=-2*Pi..2*Pi,\n shading=parse\left(DocumentTools:-GetProperty\left(\text{'}:-ComboBox0\text{'},value\right)\right)\right)\right);":$
 > $S≔\mathrm{ComboBox}\left(\left["xy","xyz","z","zgrayscale","zhue","none"\right],\mathrm{identity}="ComboBox0",\mathrm{selected}="zhue",\mathrm{action}=\mathrm{actioncode},\mathrm{fontcolor}="DarkBlue",\mathrm{tooltip}="The shading choice"\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(S\right)\right)\right)\right):$

Following insertion an item in the ComboBox may be manually selected, which causes the respective action code to execute and the "Plot0" component to be updated.

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

The ComboBox component in the previous example is constructed by supplying identity="ComboBox0" as an option. But the first example on this page had already inserted content with a component with that identity. Hence the identity of the ComboBox in the last example may be replaced at insertion time. Note that literal instances of "ComboBox0" are also replaced in all component action code of the inserted content in the last example. In particular the replacement of the literal instance of "ComboBox0" in the actioncode string will match the identity replacement. This allows the action code to function as intended, with component identities replaced consistently. This can be confirmed by selecting the inserted ComboBox and viewing the component name in the Context Panel and by clicking Edit Select Code... to view the Code Editor for this component.

Compatibility

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