List Box Component - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

List Box Component

Insert a list box in a Standard Maple worksheet or document.

 

Description

Component Palette Image

List Box Properties

List Box Example

Description

• 

The list box component performs an action or a series of actions to communicate with other embedded components when an item from the list box is selected, although assigning an action to a component is not required.

• 

To perform an action when an item from a list box is selected, click the list box, and then, from the context panel, select Edit Select Code. 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 list box is selected. For more information, see the List Box Component Example on this page.

• 

The list box component is customized by setting options in the List Box context panel. To view the List Box context panel, select the list box. Actions are associated with components using routines in the DocumentTools package.

• 

The Name property is used to reference the list box when using the routines from the DocumentTools package.

• 

To populate the list box with entries, select the Edit button beside Item List. In the List Editor that displays, add the first item by double-clicking the text field and edit 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. After you have populated the list box, select the drop-down menu beside Selected Item and choose the item that will be the default item highlighted in the list box.

Component Palette Image

List Box Properties

• 

The following table describes the control and use of the list 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

fillcolor

x

x

color

fontcolor

x

x

color

itemList

x

x

list or set

selectmultiple

x

x

true or false

selectedindices

x

x

list of non-negative integers

selectedindex

x

x

non-negative integer

selectedItemList

x

x

list or set

tooltip

x

x

string

type

x

 

string

value

x

x

string

visible

x

x

true or false

  

 

  

enabled 

  

Whether the component is enabled. If enabled is set to false, the component is grayed out and any action associated with it cannot be initiated. By default, the value is true.

  

fillcolor

  

Specifies the background 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 [255,255,255] which corresponds to white.

  

fontcolor

  

Specifies the font color of the component.  The default value is [0,0,0] which corresponds to black.

  

itemList 

  

The set of items provided in the List Box.

  

selectmultiple 

  

Indicates whether selecting multiple items is permitted. By default, the value is false.

  

selectedindices 

  

The set of all indices for items which are selected. The first index is 0.

  

selectedindex 

  

The index of the item which is selected. When multiple items are selected, it is the first index of selectedindices. The first index is 0.

  

selectedItemList 

  

The set of all items which are selected.

  

tooltip 

  

The text that appears when the user hovers the mouse over the list box.

  

type 

  

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

  

value 

  

The selected item, or if multiple items are selected, the first selected item.

  

visible 

  

Specifies if the list box is visible. By default, the value is true.

List Box Example

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

This example displays a list of colors in a List Box component. When you click on a color in the list box, the color of curve in the Plot component changes.

To insert the components and add the colors to the list box:

1. 

Insert a List Box and a Plot component using the Components palette. For information on displaying the Maple palettes, see the Show Palettes help page.

2. 

Click the list box component to open the context panel.

3. 

Click the Edit button of the Item List field.

4. 

Double-click the first row and replace ListBox with blue.

5. 

Click Add, double-click the new field, and then replace the default entry with red.

6. 

Repeat step 5 and add the following items to the list: black, green, magenta, and yellow. When finished, click OK to close the List Editor.

 

To have a list box item selection change the color of the plot of sin(x):

1. 

 Click the list box, and then 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, plot(sin(x), x = 0..10, color = GetProperty("ListBox0", 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 list box, the color of the plot changes to the selection.

  

  

 

with(DocumentTools):

  

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

SetProperty("Plot0", value, plot(sin(x), x = 0..10, color = GetProperty("ListBox0", value)));

See Also

DocumentTools

DocumentTools[GetProperty]

DocumentTools[SetProperty]

EmbeddedComponents

Maplets[Elements][ListBox]

PlotComponent