loadMenu

loadMenu(index: Integer): MenuItem;

The loadMenu method of the MenuItem class enables an existing menu item to be "cloned" at run time; that is, one or more copies of that menu item can be created at run time in the menu of the form.

The cloned menu can be a menu item created at run time (to control ordering) or it can be one created in JADE Painter.

The menu item is added to the menu directly after the menu item that is being cloned. New clone menu items are created using the runtime copy of the menu item.

Each menu item calls the same methods defined for the original menu item, passing their own menu item object as the first parameter. In addition, you must assign a unique identifier to each menu item, which is passed to the loadMenu method in the index parameter.

Menu items that are created in the JADE Painter have an index parameter value of zero (0).

Most commonly, the value of the index would be just that: an index. The values need not be sequential, but they cannot be duplicated.

An exception is raised if a MenuItem method is invoked from a server method.

The code fragment in the following example shows the creation of a new menu item.

menu := menuItem.loadMenu(count);

In this example, the menuItem value is the menu item that is being cloned, the menu value is the new copy of the menu item created, and the count value is the unique copy index supplied by the caller.

Any menu item that is added is automatically deleted when the form is destroyed. You can also delete these menu items dynamically, by using the delete instruction. To access these cloned menu items, use the getMenuItem method.