Combo Box Component
insert a drop-down list in a worksheet or document
Description
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.
The Name property is used to reference the combo box when using the routines from the DocumentTools package.
To populate the combo box with entries, click the Edit Item List button. In the List Editor that displays, add your entries.
Using the List Editor
Edit the list editor using the buttons Insert Above, Insert Below, and Remove, as well as the keyboard shortcuts listed in the following table, and the tip described below it.
Keyboard shortcuts for the list editor
Action
Windows, Linux
Mac
Activate the row and select all contents
Enter
Return
Activate the row with the contents removed
Backspace
Delete
Activate the row with the cursor at the start of the content
Left arrow
Activate the row with the cursor at the end of the content
Right arrow
Insert row above the current selection
Ctrl + K
Command + K
Insert row below the current selection
Ctrl + J
Command + J
Delete the current selection
Command + Delete
Move the selection up one row
Ctrl + Up arrow
Command + Up arrow
Move the selection down one row
Ctrl + Down arrow
Command + Down arrow
In addition, if you select one or more rows you can drag them to a new location.
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.
Option
Get
Set
Option Type
enabled
x
true or false
itemlist
list or set
fontcolor
color
selectedindex
non-negative integer
tooltip
string
type
value
visible
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 Edit Item List.
In the List Editor, in the first row, press Enter then replace the text ComboBox with xyz.
Click Insert Below, repeatedly to add four more entries.
Click on the first new item, press Enter, and then replace the default entry with xy.
Repeat step 5 to specify the following items: 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).
Click 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.
xyzxyzzgrayscalezhue
You can verify the syntax of the embedded component action by executing the command in the worksheet.
with(DocumentTools):
Using the previous example, you can extract data from the embedded component using the DocumentTools[GetProperty] tool.
GetProperty(ComboBox0, value);
xyz
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"];
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") end if;
See Also
DocumentTools
DocumentTools[GetProperty]
DocumentTools[SetProperty]
EmbeddedComponents
Maplets[Elements][ComboBox]
Download Help Document