Promotic
WikipediaLinkedInYoutubeTwitterFacebook

onKeyPress - event of the PmaRoot object

Description:
The event is triggered after pressing or releasing any key.
Parameters:
pMe(Object) Reference to the PmaRoot object where the event rises.
pEvent(Object) Reference to object describing detailed information about the specific event.
pEvent.Action - (Integer) Indication of pressing or releasing the key.
0 - key release
1 - key press
pEvent.Code - (Long) Pressed key code. In case of an ANSI character the value equals the char code, for the other codes see Keys constants.

In order to convert such numeric code into String the Pm.StringCodeFrom method can be used.

pEvent.Ctrl - (Boolean) Indication of concurrent pressing the Ctrl key.
pEvent.Shift - (Boolean) Indication of concurrent pressing the Shift key.
pEvent.Alt - (Boolean) Indication of concurrent pressing the Alt key.
Note:
The event has the same parameters as the PmgObject.onKeyPress event or the PmaPanel.onKeyPress event.
See also:
- PmaKey (object)
Example:
The following example is in the form that is automatically generated after creating a new application. 'Hot' keys are defined as follows:
- Ctrl-S for halting the application - Pm.AppStop
- Ctrl-I for calling the INFO system
- Ctrl-P for logging in the local user - Pm.WndLogon
- Ctrl-O for logging out the local user - Pm.WndLogoff
- Ctrl-G for calling the list with panels
- Ctrl-A for calling the window with alarm groups
- Ctrl-E for calling the window with event groups
JavaScriptSelect and copy to clipboard

var oCreator, sTarget;
function onViewClose(ev)
{
if (ev.CloseReason == "ok")
{
var sViewer = ev.ReturnValue;
if (Pm.IsValid(sViewer))
Pm.CreateView(Pm.GetActiveWorkspace(), sViewer, "", sTarget).Open();
}
}


if (pEvent.Action == 0 && pEvent.Ctrl && ! pEvent.Shift && ! pEvent.Alt)
{
switch (pEvent.Code)
{
case 83:  //Key S
Pm.AppStop();
break;
case 73:  //Key I
Pm.CreateView(Pm.GetActiveWorkspace(), "/#glob/infosystem", "", "target:_blank;").Open();
break;
case 80:  //Key P
Pm.WndLogon(true);
break;
case 79:  //Key O
Pm.WndLogoff(true);
break;
case 71:  //Key G
sTarget = "target:main;";
oCreator = Pm.CreateView(Pm.GetActiveWorkspace(), "/#glob/list", "autoselect:1", "target:_blank;modal:1;size:300,350;");
oCreator.View.list = Pm.FindViewers("groups:menu;viewers:panel;", "", "columns:path,title;");
oCreator.View.title = Pm.EvalMacro("$.text('sys','panelsName')");
oCreator.View.onClose = onViewClose;
oCreator.Open();
break;
case 65:  //Key A
sTarget = "target:_blank.alarms; size:1000,500;";
oCreator = Pm.CreateView(Pm.GetActiveWorkspace(), "/#glob/list", "autoselect:1", "target:_blank;modal:1;");
oCreator.View.list = Pm.FindViewers("groups:menu;viewers:alarm_state;", "", "columns:path,title,alstate3,alstate2,alstate1,alhoot;");
oCreator.View.title = Pm.EvalMacro("$.text('sys','alarmsName')");
oCreator.View.onClose = onViewClose;
oCreator.Open();
break;
case 69:  //Key E
sTarget = "target:_blank.events; size:1000,500;";
oCreator = Pm.CreateView(Pm.GetActiveWorkspace(), "/#glob/list", "autoselect:1", "target:_blank;modal:1;");
oCreator.View.list = Pm.FindViewers("groups:menu;viewers:event;", "", "columns:path,title;");
oCreator.View.title = Pm.EvalMacro("$.text('sys','eventsName')");
oCreator.View.onClose = onViewClose;
oCreator.Open();
break;
}
}
PROMOTIC 9.0.15 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