Combo Box Component - Maple Programming Help

Home : Support : Online Help : Programming : Document Tools : Embedded Components : ComboBoxComponent

Combo Box Component

Insert a drop-down list in a Standard Maple worksheet or document.

Description

 • The combo box component defines a box featuring a drop-down list in a Standard Maple worksheet or document. This component performs an action or a series of actions to communicate with other embedded components when an item from the combo box is selected, although assigning an action to a component is not required.
 • To perform an action when an item from a combo box is selected, right-click (Control-click for Macintosh) the combo box, and then select Edit Select Action to open the Code Editor dialog for the combo box. Enter the commands you want to perform in the Code Editor dialog.
 • You need to specify one or more embedded components that will display the output once an item from the combo box is selected. For more information, see the Combo Box Component Example on this page.
 • The combo box component is customized by setting options in the ComboBox Properties. To open the ComboBox Properties, right-click (Control-click for Macintosh) the combo box, and then select Component Properties. Actions are associated with components using routines in the DocumentTools package.
 • To populate the combo box with entries, click the Edit button beside Item List. In the List Editor that displays, add the first item by double-clicking the text field and editing this region. To add additional items, click the Add button to display an additional text field and proceed to edit the entry as illustrated in the previous step. Once you have populated the combo box, select the drop-down menu beside Selected Item and choose the item that will appear in the combo box when collapsed.
 • The Name property is used to reference the combo box when using the routines from the DocumentTools package.
 Component Palette Image

Combo Box Properties

 • The following table describes the control and use of the combo box component options.
 An x in the G column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.
 An x in the S column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.

Option   G  S  Option Type

enabled   x  x  true or false
itemList  x  x  list or set
fontcolor x  x  color
tooltip   x  x  string
value     x  x  string
visible   x  x  true or false

 enabled
 Indicates whether the component is enabled. Disabled components appear grayed out and their associated actions cannot be executed. By default, the value is true.
 fontcolor
 Specifies the font color of the component.  The color can be given by RGB values (a list of three integers between 0 and 255) or a string representing a color name, for example, [255,0,0] or “Red”. The default value is [0,0,0] which corresponds to black.
 itemList
 The set of choices provided in the Combo Box.
 tooltip
 The text that appears when the user hovers the mouse over the component.
 value
 The name of the item which is selected.
 visible
 Specifies if the component is visible. By default, the value is true.

Combo Box Component Example

Note: To interact with the examples provided below, open this help page as a worksheet and then execute the worksheet.

This example shows how to use a Combo Box to select a shading option for a plot and display the result in a Plot embedded component.

To insert the components and display the 3-D plot:

 1 Insert a Plot and Combo Box component using the Components palette. For information on displaying the Maple palettes, see the Show Palettes help page.
 2 Right-click (Control-click for Macintosh) the Plot component, and then select Component Properties.
 3 In the Plot Expression field, enter plot3d(x*sin(y), x=-10..10, y=-5..5).
 4 Click OK.

To add items to the combo box:

 1 Right-click (Control-click for Macintosh) the Combo Box component, and then select Component Properties.
 2 Click the Edit button of the Item List field.
 3 Double-click the first row, and then replace ComboBox with xyz.
 4 Click Add, double-click the newly added field, and then replace the default entry with xy.
 5 Repeat step 4 and enter the following items to the list: z, zgrayscale, and zhue. When finished, click OK to close the List Editor.
 6 Click OK to close the ComboBox Properties dialog.

To have a Combo Box item selection change the display of the 3-D plot:

 1 Right-click (Control-click for Macintosh) the Combo Box component, and then select Edit Select Action.

This launches the Code Editor dialog with preset statements and additional information on how to program actions between embedded components.

 2 Before the end use; statement in the dialog, enter the following command:

Note: Ensure the names of the components are correct (that is, that they match the Name fields for their components).

 3 From the File menu, select Save Code to accept all changes.
 4 From the File menu, select Close Code Editor.

When you select an item from the Combo Box, the shading of the plot changes to the selection.

You can verify the syntax of the embedded component action by executing the command in the worksheet.

 >

Using the previous example, you can extract data from the embedded component using the DocumentTools[GetProperty] tool.

 > $\mathrm{DocumentTools}:-\mathrm{GetProperty}\left(\mathrm{ComboBox0},\mathrm{value}\right)$
 ${"xyz"}$ (4.1)

You can also add items from a list to the embedded component using the DocumentTools[SetProperty] tool. Insert a second ComboBox (ComboBox1) component into the previous example, and then execute the following:

 >
 ${\mathrm{mylist}}{:=}\left[{"one"}{,}{"two"}{,}{"three"}\right]$ (4.2)
 > $\mathrm{DocumentTools}:-\mathrm{SetProperty}\left(\mathrm{ComboBox1},\mathrm{itemlist},\mathrm{mylist}\right)$

You can also set the default value of the combo box so that the value of one will change if the value of the other matches a certain condition.

 >
 >