Combo Box Component
Insert a drop-down list in a Standard Maple worksheet or document.
Component Palette Image
Combo Box Properties
Combo Box Component Example
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, click the combo box, and then from the Combo Box context panel, select Edit Select Code 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 when 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 Combo Box context panel. To display the options in the context panel, select the Combo Box. 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. This displays the List Editor. In the List Editor, add the first item by double-clicking the text field and editing this region. To add additional items, click the Add button. After 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.
The following table describes the control and use of the combo box component options.
An x in the Get column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.
An x in the Set column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.
true or false
list or set
Indicates whether the component is enabled. Disabled components appear grayed out and their associated actions cannot be executed. By default, the value is true.
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.
The set of choices provided in the Combo Box.
The index of the item which is selected. The first index is 0.
The text that appears when the user hovers the mouse over the component.
The type of the component. This returns "ComboBox".
The name of the item which is selected.
Specifies if the component is visible. By default, the value is true.
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:
Insert a Plot and Combo Box component using the Components palette. For information on displaying the Maple palettes, see the Show Palettes help page.
Click the Plot component to display the Plot context panel.
In the Plot Expression field, enter plot3d(x*sin(y), x=-10..10, y=-5..5);
To add items to the combo box:
Click the Combo Box component to display the Combo Box context panel.
Click the Edit button of the Item List field.
Double-click the first row, and then replace ComboBox with xyz.
Click Add, double-click the newly added field, and then replace the default entry with xy.
Repeat step 4 and enter the following items to the list: z, zgrayscale, and zhue. When finished, click OK to close the List Editor.
To have a Combo Box item selection change the display of the 3-D plot:
Click the Combo Box component, and then from the context panel,select Edit Select Code.
This launches the Code Editor dialog.
Before the end use; statement in the dialog, enter the following command:
SetProperty("Plot0",value,plot3d(x*sin(y), x=-10..10, y=-5..5, shading=GetProperty("ComboBox0",value)));
Note: Ensure the names of the components are correct (that is, that they match the Name fields for their components).
or from the File menu, select Save Code to accept all changes.
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.
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:
mylist := ["one", "two", "three"];
SetProperty("ComboBox1", itemlist, mylist);
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.
if GetProperty(ComboBox0, value) = "xyz" then
SetProperty(ComboBox1, value, "two")
Download Help Document
What kind of issue would you like to report? (Optional)