Managing Menus

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 2003 (Modified)


Terminology

The documentation of Menus commands uses the terms menu command and menu item interchangeably when describing a line in a menu.

Menu Bars


Each menu bar is identified by a number and by a name. The first menu bar (created automatically by 4th Dimension) has the number 1 and is named Menu Bar #1 by default. In order to rename a menu bar, Ctrl+click (Windows) or Command+click (Mac OS) on its name in the Menu editor. The name of a menu bar may contain up to 31 characters and must be unique.

Menu Bar #1 is also the menu bar used by default. To open an application with a menu bar other than Menu Bar #1, you must use the MENU BAR command in the On Startup database method.

Each menu command can have a project method or a standard action attached to it. If you do not assign a method or a standard action to a menu command, choosing that menu command causes 4th Dimension to exit the Custom Menus environment and go to the User environment. If the user is working with the 4th Dimension Custom Menus version or does not have access to the User environment, this means quitting to the Desktop.

Standard actions can be used to carry out various current operations linked to system functions (copy, quit, etc.) or to those of the 4D database (add record, select all, etc.).

You can assign both a standard action and a project method to a menu command. In this case, the standard action is never executed; however, 4th Dimension uses this action to activate/deactivate the menu command according to the current context. When a menu command is deactivated, the associated project method cannot be executed.

Every menu bar comes equipped with three menus—the File, Edit and Mode menus.

The File menu has only one menu command—Quit. The Quit standard action is assigned to it. This action displays an "Are you sure?" confirmation dialog box then quits the 4D application if this dialog box is validated. Otherwise, the operation is cancelled.

Note: Under Mac OS X, the created menu command associated with the Quit action is automatically placed in the application menu when the database is executed on this system.

You can rename the File menu, add menu commands to it or keep it as is. It is recommended that you always keep Quit as the last menu command in the File menu.

The Edit menu contains the standard editing menu commands. A standard action (Cancel, Cut, Copy, etc.) is assigned to each command of this menu. You can add commands to this menu or use your own methods for managing editing actions.

The Mode menu contains the Design, User and Custom Menus commands by default. These commands are used to access the different environments of 4D from the Custom Menus mode.

Note: 4th Dimension automatically manages the Help, Apple (Mac OS) and application (Mac OS X) system menus. These menus cannot be modified, except for the About 4th Dimension command, which can be managed using the SET ABOUT command.

Warning: Menu bars are "interprocess." Any modification carried out on a menu bar will be reflected in all the processes where the menu bar is used.

Menu Numbers and Menu Command Numbers


Like menu bars, menus are numbered. The File menu is menu 1. Thereafter, menus are numbered sequentially from left to right (2, 3, 4, and so on). Menu numbering is important when you are working, for example, with the Menu selected function. When a menu is associated with a form, the menu numbering scheme is different. The first appended menu begins with the number 2049. To refer to an appended menu, add 2048 to the normal menu number.

The menu commands within each menu are numbered sequentially from the top of the menu to the bottom. The topmost menu command is item 1.

Associated Menu Bars


You can associate a menu bar with a form in the Form properties (General page). Such a menu bar is called a "form menu bar" in this document.

The menus on a form menu bar are appended to the current menu bar when the form is displayed. The menus are appended for input forms in both the User and Custom Menus environments and for output forms in the Custom Menus environment.

Form menu bars are specified by a menu bar number and a name. If the number or name of the menu bar displayed with the current form is the same as that of the menu bar appended to the form, the menu bar is not appended.

By default, when a form is displayed with a custom menu bar, the commands of the current menu bar are deactivated, i.e. selecting them has no effect. You can modify this operation by checking the Active Menu Bar option in the Form properties: in this case, the commands of the current menu bar will remain usable.

In every case, the selection of a menu command causes an On Menu Selected event to be sent to the form method; you can then use the Menu selected command to test the selected menu.

Modifying Menu Items Programmatically


4th Dimension provides the following commands for adding, deleting, inserting or modifying menu items in a menu of the menu bar currently displayed or installed in a process:

ENABLE MENU ITEM

DISABLE MENU ITEM

SET MENU ITEM

SET MENU ITEM STYLE

SET MENU ITEM MARK

SET MENU ITEM KEY

APPEND MENU ITEM

INSERT MENU ITEM

DELETE MENU ITEM

The scope of each of these commands is the current use of the menu bar. As soon as you call MENU BAR again, all the menus and menu items will return to their original state as defined in the Design environment Menu Bar editor.

Each of these commands expects a menu and a menu item number.

As explained, menus are numbered 1 to X from left to right. For example, File is usually the first menu. The Apple (Mac OS) and Application (Mac OS X) menus are excluded from this numbering. The Help menu is also excluded no matter what the platform.

Note that the Count menus command does not take these menus into account. For example, if you have a menu bar composed of the File, Edit, Customers, Invoices and Help menus, Count menus will return 4, ignoring the system menus maintained by 4D.

Menu items are numbered 1 to X, from top to bottom, including separator lines.

Menus that are inserted in the menu bar by means of a menu bar associated with a form, and therefore appended to the current menu bar, are numbered from left to right starting with the number 2049 (2048 + 1 to X).

The Menu selected command returns menu and menu item numbers using that convention.

Warning: These commands cannot access the system menus.

Connected Menus: Menus can be connected to menu bars. If a connected menu is modified using one of these commands, every other instance of the menu will reflect these changes. For more information about connecting menus, refer to the 4th Dimension Design Reference Manual.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next