GRIDPLUS2 - Dropdown Grid
Home Reference Manpage Examples Download License Contact

GRIDPLUS Dropdown Grid

In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS dropdown command mode. This command mode is a "short cut" method to invoke the GRIDPLUS widget command mode with the default widget set create dropdowns. All of the normal widget command mode functionality can be used. For example creating other widget types.

This uses a simple syntax to create a grid of dropdowns. The syntax is closely based on the GRIDPLUS Grid and Widget.

GRIDPLUS Dropdown Specific Item Options/Functionality

See GRIDPLUS Widget Grid for a full list of item options/functionality.

~command
Specifies that a command is invoked when a dropdown item is selected. The command name is optional. If not specified command name is based on the name of dropdown.

=default
Specifies the default value to be used for a dropdown when the widget is created (Example: "=Default Option").

integer
Specifies a positive integer which overrides the default width for the dropdown.

Example

This section contains an example which illustrates the main GRIDPLUS dropdown command mode features.

The following example assumes that the reader is familiar with the contents of the Grid/Layout and Widget pages. Information given on that page will not be duplicated here.

Note: The example assumes that the GRIDPLUS package has already been "required" and the commands imported.


Dropdown Example

Window:

Source Code:

gridplus dropdown .mygrid -title "My Grid" -width 20 -wtitle "Dropdown Example" {
   {"Dropdown One" .dropdown1 {+"Option one" "Option two" "Option three"}}
   {"Dropdown Two" .dropdown2}
}

pack .mygrid

Comments:

When using the GRIDPLUS dropdown command mode the "label" defines the text that will appear as a label to the associated dropdown. The cell item begining with a dot is the widget (dropdown) ID. The dropdowns are created with names based on the name of the containing Grid and the widget ID.

For example: The for the ".mygrid" cell defined by "{"Dropdown Two" .dropdown2}" a dropdown widget is created with the name ".mygrid,dropdown2". Please note that the widget name does contain a comma - this is not a misprint!!

In ".mygrid" the widget IDs are to the right of the label text. This will create dropdowns which are to the right of the label text.

The item option begining with "+" specifies the list of options for the dropdown. The first item in the list will be used as the value of the dropdown. It is possible to both the value and the dropdown list using the gpset command (See Below)

Reading and Setting GRIDPLUS Dropdown Values/Lists

The values of the GRIDPLUS widgets are stored in a global array with a null name.

For Example:

global {}

For GRIDPLUS Dropdown widgets the array element has the same name as the widget: Thus the value of ".dropdown1" in ".mygrid" is referenced as "$(.mygrid,dropdown1)".

The recommended method to set GRIDPLUS entry values is to use the gpset command.

The gpset command can also be used to set the dropdown list.

For Example:

To set the value of the dropdown use gpset with one parameter...

gpset {.mygrid,dropdown1 "Option two"}

To set the dropdown list use gpset with two parameters...

gpset .mygrid,dropdown2 {"Option 1" "Option 2" "Option 3"}


Copyright © 2012 Adrian Davis.