Promotic
WikipediaLinkedInYoutubeTwitterFacebook

AddMenu - method of object PmMenu

Description:
Add one item to the menu.
Syntax:
Empty AddMenu(String sId, String sText, [String sOptions])
Calling:
pEvent.Menu.AddMenu sId, sText, sOptions
Parameters:
sId(String) Identifier of the menu item.

This identifier can be used in the onMenuSelect event to detect which menu item has been selected.

It is possible to enter an empty string ("") if this item is not being used in the onMenuSelect event (e.g. separator or text that is not used for selection).

The submenu items are referred to by compound identifier. The identifier consists of submenu identifier, separator (/) and item identifier. Items not included in the submenu have simple identifier without separator (full stop).

sText(String) Displaid text of the menu item. Macro expression can be used for input ($.text ..) (it is evaluated while calling a method).
sOptions[optional] (String) Additional parameters added items. Entries are in KeyVal format, for example "type:checkedtext;enabled:0;".
"type:sss;" (optional) - Specifies the type of added item.
type:text; (default) - The added item is text.
type:checkedtext; - The added item is text, marked as selected (checkbox on the left from the text).
type:separator; - The added item is a separator, i.e. a horizontal line is created. Parameter sText has no meaning.
type:menu; - The added item is a submenu, i.e. a text and submenu mark is created. The submenu has its identifier and the contained items also have identifiers. A compound identifier is created with full stop separator (/).
"enabled:n;" (optional) - Specifies whether the added item is allowed or disabled (1 = enabled (default), 0 = disabled).
Note:
This property is also functional for Web panels. So far is not functional type:checktext;.
Example:
Script - the onMenuFill event: Creates the menu with 4 rows (START, STOP, PAUSE, Help) and submenu with 2 rows (Index, About).
JavaScriptVBScriptSelect and copy to clipboard

pEvent.Menu.AddMenu("start", "START");
pEvent.Menu.AddMenu("stop", "STOP");
pEvent.Menu.AddMenu("pause", "PAUSE");
pEvent.Menu.AddMenu("", "", "type:separator;");
pEvent.Menu.AddMenu("help", "Help", "type:menu;");
pEvent.Menu.AddMenu("help/index", "Index");
pEvent.Menu.AddMenu("help/about", "About");
 
Script - the onMenuSelect event: Execution of the appropriate action after the activation of the menu item by the user.
JavaScriptVBScriptSelect and copy to clipboard

switch (pEvent.Name)
{
case "start":
pMe.PmPanel.Methods.Start();
break;
case "stop":
pMe.PmPanel.Methods.Stop(1);
break;
case "pause":
pMe.PmPanel.Methods.Stop(0);
break;
case "help/index":
pMe.PmPanel.Methods.ShowHelpIndex();
break;
case "help/about":
pMe.PmPanel.Methods.ShowAboutDlg();
break;
}

History:
Pm8.03.24:
- Multi level menus can now be created - by method AddMenu("id", "text", "type:menu;") it is now possible to add a submenu.
Pm7.03.09: Created
PROMOTIC 9.0.6 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice