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

Online Help

All Products    Maple    MapleSim


Maplets[Elements]

  

DropDownBox

  

define a drop-down box

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

DropDownBox(opts, dropdown_box_content)

DropDownBox[refID](opts, dropdown_box_content)

Parameters

opts

-

equation(s) of the form option=value where option is one of background, enabled, font, foreground, halign, height, onchange, reference, tooltip, valign, value, visible, or width; specify options for the DropDownBox element

dropdown_box_content

-

any number of Item elements, or a list of strings or symbols; items that appear in the drop-down box

refID

-

name or string; reference to the element

Description

• 

The DropDownBox window body element defines a drop-down box in a Maplet application. A drop-down box allows the user to select an item from a predefined list. The selected item is returned as a list containing a string.

  

 

• 

The DropDownBox element features can be modified by using options. To simplify specifying options in the Maplets package, certain options and contents can be set without using an equation. The following table lists elements, symbols, and types (in the left column) and the corresponding option or content (in the right column) to which inputs of this type are assigned by default.

Elements, Symbols, or Types

Assumed Option or Content

 

 

Font element

font option

refID

reference option

string or symbol

value option

 

 

• 

A drop-down box is different from a combo box. The user must select an item from the drop-down box's predefined list. A combo box allows the user to enter other text.

• 

A DropDownBox element can contain Item elements. A DropDownBox element can contain Action or command elements to specify the onchange option and a Font element to specify the font option.

• 

A DropDownBox element can be contained in a Maplet or BoxLayout element, or Maplet element in a nested list representing a box layout.

• 

The following table describes the control and use of the DropDownBox element options.

  

An x in the I column indicates that the option can be initialized, that is, specified in the calling sequence (element definition).

  

An x in the R column indicates that the option is required in the calling sequence.

  

An x in the G column indicates that the option can be read, that is, retrieved by using the Get tool.

  

An x in the S column indicates that the option can be written, that is, set by using the SetOption element or the Set tool.

Option

I

R

G

S

 

 

 

 

 

appenditem*

 

 

 

x

background

x

 

x

x

enabled

x

 

x

x

font

x

 

x

x

foreground

x

 

x

x

halign

x

 

 

 

height

x

 

 

 

itemlist*

 

 

x

x

onchange

x

 

 

 

reference

x

 

 

 

tooltip

x

 

x

x

valign

x

 

 

 

value

x

 

x

x

visible

x

 

x

x

width

x

 

 

 

 

 

 

 

 

  

* appenditem appends an item to the list of items in the drop-down box. Its syntax is refID(appenditem)="text", where refID is a reference to the drop-down box.

  

* itemlist overwrites the existing list.  Its syntax is Maplets:-Tools:-Set(refID(itemlist)=[item1, item2, ..., itemn]), where refID is a reference to the drop-down box and item1, item2, ..., itemn are the new items for the drop-down box.

• 

The opts argument can contain one or more of the following equations that set Maplet application options.

  

 

  

background = color

  

The color of the drop-down box.  This can be a recognized color name, an RGB color structure, or a string of the form "#RRGGBB" where each pair is a two-digit hexadecimal number.

  

 

  

enabled = true or false

  

Whether an item from the drop-down box can be selected.  If enabled is set to false, the drop-down box is dimmed, and any action associated with it cannot be initiated.  By default, the value is true.

  

 

  

font = Font element or reference to a Font element (name or string)

  

The text font in the drop-down box.

  

 

  

foreground = color

  

The text color in the drop-down box.  This can be a recognized color name, an RGB color structure, or a string of the form "#RRGGBB" where each pair is a two-digit hexadecimal number.

  

 

  

halign = left, center, or right

  

Specifies the horizontal alignment for the drop-down box contents. By default, this is left.

  

 

  

height = nonnegint

  

The height in pixels. By default, the drop-down box is sized to fit its content. When both the height and width are set to zero, this tells the drop-down box to size itself based on the layout instead of the content. This means, for example, that when present in a GridLayout using full alignment, the combo box will size itself to fit the GridCell.

  

 

  

onchange = Action or command element, or reference to an Action element (name or string)

  

The action that occurs when the value of the drop-down box changes.

  

 

  

reference = name or string

  

A reference for the DropDownBox element.

  

If the reference is specified by both an index, for example, DropDownBox[refID], and a reference in the calling sequence, the index reference takes precedence.

  

 

  

tooltip = string

  

The text that appears in the tooltip help window.

  

 

  

valign = top, center, or bottom

  

Specifies the vertical alignment for the drop-down box contents.

  

 

  

value = string or symbol

  

The initial value of the drop-down box.  If no value is specified, or if the value is not an item in the drop-down box, the initial value is the first item specified in dropdown_box_content.

  

 

  

visible = true or false

  

Whether the drop-down box is visible to the user.  By default, the value is true.

  

 

  

width = nonnegint

  

The width in pixels. By default, the drop-down box is sized to fit its content. When both the height and width are set to zero, this tells the drop-down box to size itself based on the layout instead of the content. This means, for example, that when present in a GridLayout using full alignment, the combo box will size itself to fit the GridCell.

Examples

withMapletsElements:

mapletMapletPick your favorite Canadian city: ,DropDownBoxDDB1Regina,sortWaterloo,Ottawa,Victoria,Edmonton,Regina,Winnipeg,Toronto,Quebec City,Fredericton,Halifax,Charlottetown,St. John's,Whitehorse,Yellowknife,Iqaluit,lexorder,ButtonOK,ShutdownDDB1,ButtonCancel,Shutdown:

MapletsDisplaymaplet

The following example shows how to create a maplet dialog that uses a predefined procedure to adaptively set properties of entry fields.

First, a procedure is defined which sets text fields to active or not active depending on the choice from the drop-down list. The label is also modified accordingly.

withMapletsElements:

ElementController := proc()
    local val;
    val := Maplets:-Tools:-Get( 'DDB1' );
    if val in { "1" } then
        Maplets:-Tools:-Set( 'IF1'( 'enabled' ) = 'true', 'IF2'( 'enabled' ) = 'false', 'LB1'( 'caption' ) = "Active", 'LB2'( 'caption' ) = "Field 2" );
    else
        Maplets:-Tools:-Set( 'IF1'( 'enabled' ) = 'false', 'IF2'( 'enabled' ) = 'true', 'LB1'( 'caption' ) = "Field 1", 'LB2'( 'caption' ) = "Active" );
    end if;
    return NULL;
end proc:

Next, the maplet dialog is defined:

MapletDialogMapletWindowtitle=Example,Choose from the following list:,DropDownBoxDDB1value=1,1,2,onchange=Evaluatefunction=ElementController,LabelLB1Active,TextFieldIF110,LabelLB2Field 2,TextFieldIF210,enabled=false,ButtonClose,ShutdownDDB1,IF1,IF2:

Maplets:-DisplayMapletDialog

See Also

Maplets/CommandElements

Maplets/WindowBodyElements

Maplets[Display]

Maplets[Elements]

Maplets[Elements][Action]

Maplets[Elements][Button]

Maplets[Elements][ComboBox]

Maplets[Elements][Font]

Maplets[Elements][Item]

Maplets[Elements][Maplet]

Maplets[Elements][SetOption]

Maplets[Elements][Shutdown]

Maplets[Tools][Get]

Maplets[Tools][Set]

Overview of Maplet Applications

sort