Page 427
FIG. 16.18
A new menu module on
the object navigator.
FIG. 16.19
A newly created menu
object.
FIG. 16.20
The Menu Editor used
to layout the menu
options.
In the first block of buttons on the left of the editor are the preceding buttons: cut, copy, paste, copy properties, and paste property tools, respectively. These tools have the same functionality as buttons on other editors that have been discussed.
The middle three tools are the most commonly used on this screen.
The left tool with the downward pointing arrow is the create down tool and is used to create a new menu option below the currently selected option.
Page 428
The middle tool with the right pointing arrow is the create right tool. It creates a new menu option to the right of the currently selected option.
The tool with the red X symbol is the delete option tool, which is used to delete the selected object.
The four tools on the left side of the menu editor are shown above. They are the expand, collapse, expand all, and collapse tools respectively.
Change the label of an option, double-click the option. This will change the color of the label and allow the developer to edit the label.
Figure 16.21 displays the menu editor after the label was changed.
FIG. 16.21
The Menu Editor after
the menu option label
was changed.
Options placed on the menu become items under the menu object on the Object Navigator. Figure 16.22 shows the Employees item on the object navigator.
FIG. 16.22
The Employees option
on the object navigator.
The last step in creating a menu is to add the PL/SQL script to the item. Double-clicking the icon next to the Employees item will open the menu option's PL/SQL editor. The PL/SQL code block can then be entered.
Page 429
This section will illustrate the creation of a menu and its subsequent use in an Employee system. You may perform the following steps to create the Employee system menu:
The first step is to create a menu module.
FIG. 16.23
The Employee Menu
layout.
Page 430
FiG. 16.24
The object navigator and
the Employee menu
options.
Table 16.1Menu Options That Require a PL/SQL Code Block
Menu | Item | Command | |
Main_menu | Exit | exit_form; | |
Employees_menu | Directory | call_form | (`d:\dirch16.fmx'); |
Employees_menu | Employee_update | call_form (d:\empch16a.fmx'); | |
Miscellaneous_menu | Department | call_form (`d:\depch16.fmx', no_hide); | |
Miscellaneous_menu | Security | message | (`Not available yet'); |
CAUTION |
Two common errors occur when developing menus. The first error is failing to generate the menu before using it. When developing a form, the developer does not have to generate the form because Designer usually |
Page 431
generates it before executing the form. This is a Designer runtime option. This option does not apply to menus. Because they are never run like a form, there is not automatic generation. It is very common for a developer to make changes, run a form and corresponding menu, only to find the menu changes do not appear. |
FIG. 16.25
The PL/SQL editor and
code block for the
Employee directory
menu option.
A menu must be linked to an application in order to be executed. The menu is linked to a form by means of the form's Menu Module property. This property is located in the form object property sheet. It denotes the name and location of the menu that will be used with the form. Figure 16.26 shows a Form object property sheet. The Menu Module property specifies the menu file used for the form. The form uses the specified file when the Use File property is set to true.
FIG. 16.26
A Form object property
sheet.