Adding a Toolbar

A toolbar presents buttons on the form associated with actions defined by the current interactive BDL instruction in your program.

Figure: A form with a toolbar displayed on Windows™ platforms

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

The TOOLBAR section of a form specification file defines a toolbar with buttons that are bound to actions. A toolbar definition can contain the following elements:

  • an ITEM - specifies the action that is bound to the toolbar button
  • a SEPARATOR - a vertical line

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

The toolbar commands are enabled by actions defined by the current interactive BDL instruction, which in our example is the MENU statement in the custquery.4gl module. When a toolbar button is selected by the user, the program triggers the action to which the toolbar button is bound.

Example: (in custform.per)

The toolbar in this example will display buttons for find, next, previous, and quit actions.

Form custform.per:
01 SCHEMA custdemo 
02
03 TOOLBAR
04   ITEM find  
05   ITEM previous 
06   ITEM next 
07   SEPARATOR
08   ITEM quit (TEXT="Quit", COMMENT="Exit the program", IMAGE="exit")
09 END
10
...
Note:
  • Line 04 The ITEM command-identifier find will be bound to the MENU statement action find on line 14 in the custmain.4gl file. The word find must be identical in both the TOOLBAR ITEM and the MENU statement action, and must always be in lowercase. The other command-identifiers are similarly bound.
  • Line 08 Although attributes such as TEXT or COMMENT are defined for the ITEM quit, the items find, previous, and next do not have any attributes defined in the form specification file. These actions are common actions that have default attributes defined in the action defaults file.