Menus and menu items

Usually, all windows in an application have menus except child and response windows. Menus are lists of related commands or options (menu items) that a user can select in the currently active window. Each choice in a menu is called a menu item. Menu items display in a menu bar or in drop-down or cascading menus.

About Menu objects

Each item in a menu is defined as a Menu object in PowerBuilder. You can see the Menu object in the list of objects in the Browser's System tab.

Using menus

You can use menus you build in PowerBuilder in two ways:

  • In the menu bar of windows

    Menu bar menus are associated with a window in the Window painter and display whenever the window is opened.

  • As pop-up menus

    Pop-up menus display only when a script executes the PopMenu function.

Both uses are described in this chapter.

Designing menus

PowerBuilder gives you complete freedom in designing menus, but you should follow conventions to make your applications easy to use. For example, you should keep menus simple and consistent; group related items in a drop-down menu; make sparing use of cascading menus and restrict them to one or two levels.

This chapter describes some guidelines you should follow when designing menus. A full discussion of menu design is beyond the scope of this book. You should acquire a book that specifically addresses design guidelines for graphical applications and apply the rules when you use PowerBuilder to create your menus.

Building menus

When you build a menu, you:

  1. Specify the appearance and behavior of the menu items by setting their properties.

  2. Build scripts that determine how to respond to events in the menu items. To support these scripts, you can declare functions, structures, and variables for the menu.

There are two ways to build a menu. You can:

  1. Build a new menu from scratch. See Building a new menu.

  2. Build a menu that inherits its style, functions, structures, variables, and scripts from an existing menu. You use inheritance to create menus that are derived from existing menus, thereby saving yourself coding and time. See Using inheritance to build a menu.