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.



Component Palette Image

List Box Properties

List Box Example



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, right-click (Control-click for Macintosh) the list box, and then select Edit Select Action to open the Code Editor dialog for the list 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 once 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 ListBox Properties. To open the ListBox Properties, right-click (Control-click for Macintosh) the list box, and then select Component Properties. 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. Once 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 G column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.


An x in the S column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.

Option           G  S  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
selectedItemList x  x  list or set   
tooltip          x  x  string        
value            x  x  string        
visible          x  x  true or false




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.




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.




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




The set of items provided in the List Box.




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




The set of all items which are currently selected.




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




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




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

List Box Example

Note: To interact with the examples 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:


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.


Right-click (Control-click for Macintosh) the list box component, and then select Component > Component Properties.


Click the Edit button of the Item List field.


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


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


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.


Click OK to close the ListBox Properties dialog.

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


Right-click (Control-click for Macintosh) the list box, and then select Edit Select Action.

This launches the Code Editor dialog with preset statements and additional information on how to program actions between embedded components.


Before the end use; statement in the dialog, enter the following command:

Do(%Plot0=plot(sin(x), x=0..10, color=%ListBox0));

Note: Ensure the names of the components are correct (that is, that they match the Name fields for their components).


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 list box, the color of the plot changes to the selection.





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

DocumentTools[Do](%Plot0 = plot(sin(x), x = 0..10, color = %ListBox0));

See Also