Adding a Topmenu

A topmenu presents a pull-down menu on a form, composed of actions defined by the current interactive BDL instruction in your program.

The same options that were displayed to the user as a toolbar can also be defined as buttons on a pull-down menu ( a topmenu). To change the presentation of the menu options to the user, simply modify and recompile the form specification file.

Figure: A form with a topmenu displayed on a Windows™ platform


This figure is a screenshot of the custform form with a toolbar added in Chapter 5.

The TOPMENU section of the form specification allows you to design the pull-down menu. The TOPMENU section must appear after SCHEMA, and must contain a tree of GROUP elements that define the pull-down menu. The GROUP TEXT value is the title for the pull-down menu group.

A GROUP can contain the following elements:

  • a COMMAND - specifies the action the menu option must be bound to
  • a SEPARATOR - a horizontal line
  • GROUP children - a subgroup within a group.

Values can be assigned to attributes such as TEXT, COMMENT, and IMAGE for each item in the TOPMENU.

As in a toolbar, the TOPMENU commands are enabled by actions defined by the current interactive BDL instruction (dialog), which in our example is the MENU statement in the custquery.4gl module. When a TOPMENU option is selected by the user, the program triggers the action to which the TOPMENU command is bound.

Example ( in custform.per)

The example shows a TOPMENU section in the form specification file (custform.per) for Chapter 5.

Form custform.per:
01 SCHEMA custdemo 
02
03 TOPMENU
04   GROUP form (TEXT="Form")
05     COMMAND quit (TEXT="Quit", COMMENT="Exit the program", IMAGE="exit")
06   END
07  GROUP stores (TEXT="Stores")
08     COMMAND find 
09     SEPARATOR
13     COMMAND next     
14     COMMAND previous 
15  END
16END
17
...
Note:
  • Lines 04 and 07 This example TOPMENU will consist of two groups on the menu bar of the form. The TEXT displayed on the menu bar for the first group will be Form, and the second group will be Stores.
  • Line 08 to 14 Under the menu bar item Stores, the command-identifier find on line05 will be bound to the MENU statement action find on line 14 in the custmain.4gl file. The word find must be identical (including case) in both the TOPMENU command and the MENU statement action. The other command-identifiers are similarly bound.

The revised form specification file must be recompiled before it can be used in the program.