Combo Box Component - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Combo Box Component

insert a drop-down list in a worksheet or document

 

Description

Component Palette Image

Combo Box Properties

Combo Box Component Example

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, 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

Left arrow

Activate the row with the cursor at the end of the content

Right arrow

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

Delete

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.

Component Palette Image

Combo Box Properties

• 

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

x

true or false

itemlist

x

x

list or set

fontcolor

x

x

color

selectedindex

x

x

non-negative integer

tooltip

x

x

string

type

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.

  

selectedindex 

  

The index of the item which is selected. The first index is 0.

  

tooltip 

  

The text that appears when the user hovers the mouse over the component.

  

type 

  

The type of the component. This returns "ComboBox".

  

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. 

Click  the Plot component to display the Plot context panel.

3. 

In the Plot Expression field, enter plot3d(x*sin(y), x=-10..10, y=-5..5);

 

To add items to the combo box:

1. 

Click the Combo Box component to display the Combo Box context panel.

2. 

Click Edit Item List.

3. 

In the List Editor, in the first row, press Enter then replace the text ComboBox with xyz.

4. 

Click Insert Below, repeatedly to add four more entries.

5. 

Click on the first new item, press Enter, and then replace the default entry with xy.

6. 

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:

1. 

Click the Combo Box component, and then from the context panel,select Edit Select Code.

This launches the Code Editor dialog.

2. 

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).

3. 

Click  or 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.

with(DocumentTools):

SetProperty("Plot0",value,plot3d(x*sin(y), x=-10..10, y=-5..5, shading=GetProperty("ComboBox0",value)));

 

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

GetProperty(ComboBox0, value);

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:

mylist := ["one", "two", "three"];

mylist:=one,two,three

(4.2)

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