GRIDPLUS - Entry Grid
Home Reference Manpage Examples Download License Contact

GRIDPLUS Entry Grid

In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS entry command mode. This uses a simple syntax to create a grid of entries. The syntax is closely based on the GRIDPLUS Grid.

Note: GRIDPLUS entry widgets can support Validations.

GRIDPLUS Entry Item Options

.name
The name of the widget (Example: .b1).

%group
The name of the group to which the entry belongs (Example: %mygroup1).

<
Create entry with disabled state. Overrides -state option.

>
Create entry with normal state. Overrides -state option.

@name
Insert specfied grid/layout/widget (Example: @myoptions).

+
Specifies that the entry should have keyboard focus.

!name
Specifies name of validation to be used for entry (Example: !int)

~command
Specifies that a command is invoked when the enter key is pressed while the entry has focus. The command name is optional. If not specified command name is based on the name of entry.

*
Specifies that the entry should display "*" for each character entered.

integer
Specifies a positive integer which overrides the default size for the entry.

Example

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

The following example assumes that the reader is familiar with the contents of the Grid/Layout page. 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.


Entry Example 1

Window:

Source Code:

gridplus entry .mygrid1 -title "My Grid 1" {
  {"Label1" .1} {"Label2" .2} {"Label3" .3}
  {"Label4" .4} {"Label5" .5} {"Label6" .6}
  {"Label7" .7} {"Label8" .8} {"Label9" .9}
}

gridplus entry .mygrid2 -title "My Grid 2" {
  {.1 "Label1"}
  {.2 "Label2"}
  {.3 "Label3"}
  {.4 "Label4"}
}

gridplus entry .mygrid3 -size 15 -title "My Grid 3" {
  {}         {"Label A:c"} {"Label B:c"}
  {"Label1"} {.1}    {.2}
  {"Label2"} {.3}    {.4}
  {"Label3"} {.5}    {.6}
  {"Label4"} {.7}    {.8}
}

gridplus layout .main -title "Entry Example" {
   .mygrid1:ew  -
   .mygrid2:ns  .mygrid3:ew
}

pack .main

Comments:

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

For example: The for the ".mygrid1" cell defined by "{"Label2" .2}" an entry widget is created with the name ".mygrid1,2". Please note that the widget name does contain a comma - this is not a misprint!!

In ".mygrid2" the widget IDs are to the left of the label text. This will create entries which are to the left of the label text.

In ".mygrid3" each cell definition contains only a widget ID or label text. In this example a "matrix" of entries is created, each row and each column has one label. A "null" cell definition is used to create an empty cell in the top left of the Grid. ".mygrid3" also has the -size 15 option set. This sets the default entry size to "15" characters (The normal default is "8" characters).

The column labels ("Label A" and "Label B") have a :c suffix - This causes the labels to be centred in the containing cell.


Entry Example 2

Window:

Source Code:

gridplus entry .mygrid1 -size 20 -title "Person Details" {
  {"First Names " .1 +} {"Address" .2}
  {"Last Name" .3}      {"" .4}
  {"Age" .6 3}          {"" .5}
  {}                    {"Zip Code " .7 8}
}

gridplus layout .main -title "Entry Example" {
   .mygrid1
}

pack .main

Comments:

In this example the cell defined by "{"First Names " .1 +}" has the + option set. This causes the associated entry to be given keyboard focus when created. If more than one entry for a window is given focus the last one will take effect.

Note: The label in this cell has a trailing space. Adding one or more trailing spaces to the end of the longest label for a column will create additional space between the labels and the associated (entry) widgets.

".mygrid1" also has the -size 20 option set. This sets the default entry size to "20" characters.

In ".mygrid1" the cells defined by "{"Age" .6 3}" and "{"Zip Code " .7 8}" have a different size, in this case "3" and "8" characters respectively. If the cell definition contains an integer, this number is used as the size for the entry, overriding the default.

Cell definitions "{"" .4}" and "{"" .5}" demontrate that labels can have a null value.

Reading and Setting GRIDPLUS Entry Values

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

For Example:

global {}

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

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

For Example:

gpset .mygrid1,1 "John Paul"


Copyright © 2004 Adrian Davis.