|
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, 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
|
|
|
|
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
|
visiblerows
|
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 indices for items which are selected. The first index is 0.
|
|
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.
|
|
The set of all items which are selected.
|
|
The text that appears when the user hovers the mouse over the list box.
|
|
The type of the component. This returns "ListBox".
|
|
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.
|
|
Specifies the number of rows of the list box that are displayed. (A scroll bar is added if the size of the item list is greater than visiblerows. By default, the list box size is determined by the number of items in the item list.
|
|
|
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.
|
4.
|
In the List Editor, in the first row, press Enter then replace the text ListBox with blue.
|
5.
|
Click Insert Below to add a new item.
|
6.
|
Click on the new item, press Enter, and then replace the default entry with red.
|
7.
|
Click Insert Below, repeatedly to add four more entries.
|
8.
|
Repeat step 6 to specify the following items: 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.
|
|
|
|
|
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)));
|
|
|
|