Promotic
WikipediaLinkedInYoutubeTwitterFacebook

AddMenu - method of the PmMenu object

Description:
Add one item to the menu.
Syntax:
Empty AddMenu(String sId, String sText, [String 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:text;enabled:1;text2:Ctrl+I;".
"type:sss;" (optional) - Specifies the type of added item.
type:text; (default) - The added item is text.
type:checkedtext; - The added item is text and checkbox on the left from the text.
type:separator; - The added item is a separator, i.e. a horizontal line is created. The sText parameter 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.
enabled:1; (default) - enabled
enabled:0; - disabled
"text2:sss;" (optional) - For item of the text type, allows enetering the second text to the right side column of the menu (usually a key shortcut e.g. Ctrl+I).
Note:
This property is also functional in Web panels.
See also:
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:
Pm9.00.16: New "text2:sss;" parameter that allows entering text to the second column in the menu.
Pm9.00.14: The type:checkedtext; parameter is now functional also for Web panels.
Pm8.03.24: New type:menu; parameter allows to create multi-level menus.
PROMOTIC 9.0.16 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