Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Object PmMenu (Menu)

Description:
The local menu of graphic item or the system menu of application.
Properties and methods:
AddMenu Add one item to the menu
Note:
This object is functional also for Web Panels.
 
If the user opens the local menu of the graphic item then the PmiItem.onMenuFill event is called. In this event the PmMenu object can be filled (available in the parameter pEvent.Menu).

Then the local menu is opened with filled content.

Once the user selects the item then the menu is closed and the PmiItem.onMenuSelect event is called. In this event it is possible to detect which menu item was selected and execute the corresponding action.

 
Calling the item local menu:
- If the user clicks by the right mouse button over the graphic item.
- If the Open the local menu also by left mouse button configurator is set then also by clicking the left mouse button or pressing the space key.
- In script using the ShowMenu method (in special cases).
 
Application system menu work the same way. However it is called by the Alt-space keys or by clicking the mouse on the application icon. The the PmRoot.onSystemMenuFill and PmRoot.onSystemMenuSelect events are called.
 
The fact that the script creates the local menu of the graphic item at the moment of calling the menu, means that the local menu can hold different content at each calling.
 
Caution: The PmMenu object is valid only in the processing of the onMenuFill event. It is not allowed to save the reference to this object for the later use.
Example for VBScript:
The onMenuFill event: Creation of the menu with two rows.
pEvent.Menu.AddMenu "Start", "Switching on the unit"
pEvent.Menu.AddMenu "Stop", "Switching off the unit"
The onMenuSelect event: Execution of the appropriate action for the activation of the menu item by the user.
  Case "Start"
    pMe.PmPanel.Methods.Start
  Case "Stop"
    pMe.PmPanel.Methods.Stop
End Select
Example for JavaScript:
The onMenuFill event: Creation of the menu with two rows.
pEvent.Menu.AddMenu("Start", "Switching on the unit");
pEvent.Menu.AddMenu("Stop", "Switching off the unit");
The onMenuSelect event: Execution of the appropriate action for the activation of the menu item by the user.
{
case "Start":
  pMe.PmPanel.Methods.Start();
  break;
case "Stop":
  pMe.PmPanel.Methods.Stop();
  break;
}
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice