DocumentTools[Components]
ComboBox
generate XML for a ComboBox Component
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
ComboBox( L, opts )
L
-
(optional) list; list of strings.
opts
(optional) ; one or more keyword options as described below
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.
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.
with⁡DocumentTools:
with⁡DocumentTools:-Components:
with⁡DocumentTools:-Layout:
L≔A,B,C
Executing the ComboBox command produces a function call.
S≔ComboBox⁡L,identity=ComboBox0
S≔_XML_EC-ComboBox⁡id=ComboBox0,enabled=true,fontcolor=[0,0,0],visible=true,A,B,C
By using commands from the DocumentTools:-Layout package a nested function call can be produced which represents a worksheet.
xml≔Worksheet⁡Group⁡Input⁡Textfield⁡S:
That XML representation of a worksheet can be inserted directly.
InsertContent⁡xml:
ABC
S≔ComboBox⁡L,identity=ComboBox0,selected=B,tooltip=My example ComboBox:
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.
lookup≔InsertContent⁡xml,output=table
lookup≔table⁡ComboBox0=ComboBox1
lookupComboBox0
ComboBox1
GetProperty⁡lookupComboBox0,value
B
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≔plot3d⁡x⁢sin⁡y,x=−10..10,y=−2⁢π..2⁢π,shading=zhue:
P≔Components:-Plot⁡p,identity=Plot0:
The action code consists of multi-line statements supplied as a string.
actioncode≔DocumentTools:-SetProperty(':-Plot0',value,\n plot3d(x*sin(y), x=-10..10, y=-2*Pi..2*Pi,\n shading=parse(DocumentTools:-GetProperty(':-ComboBox0',value))));:
S≔ComboBox⁡xy,xyz,z,zgrayscale,zhue,none,identity=ComboBox0,selected=zhue,action=actioncode,fontcolor=DarkBlue,tooltip=The shading choice:
xml≔Worksheet⁡Group⁡Input⁡Textfield⁡P,Group⁡Input⁡Textfield⁡S:
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.
xyxyzzzgrayscalezhuenone
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.
The DocumentTools:-Components:-ComboBox command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
The DocumentTools:-Components:-ComboBox command was updated in Maple 2016.
The fontcolor option was introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
See Also
Component Code
Component Constructors
DocumentTools
Embedded Components
XMLTools
Download Help Document