Combo Box Component - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

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.

• 

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.

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

 

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]