Product Information > JADE Encyclopaedia of Classes – Volume 2 > Chapter 1 - System Classes > setEventMapping

setEventMapping

setEventMapping(eventName:  String;
                mappedName: String);

The setEventMapping method of the MenuItem class enables the method that is to be executed for an event to be dynamically set at run time. (See also the setEventMapping method of the Window class.)

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

By default, the JADE development environment allows the definition of event methods (menu-name_event-name) for a menu; for example:

mTickerTimer_click(menuItem: MenuItem input) updating;

Using the JADE Painter, this default mapping can be overridden by providing a specific method name to be executed when the event occurs. This method then provides the runtime ability to define the method to be called when the event occurs.

The parameters of the setEventMapping method are listed in the following table.

Setting Description
eventName Must be a defined event name for the menu; for example, click (case-independent).
mappedName The name of the method that is to be called. This method must exist on the form that is the parent of the menu for which you are calling the setEventMapping method or a method of the form that is calling the setEventMapping method.

The code fragment in the following example shows the use of the setEventMapping method.

mTickerTimer.setEventMapping("click", "myOtherMenu");

The method checks that:

As this call is relatively expensive, it should be used sparingly.