Promotic
WikipediaLinkedInYoutubeTwitterFacebook

onKeyPress - event of object PmRoot

Description:
The event fires on pressing or releasing any key.
Parameters:
pMe(Object) Reference to the Promotic object where the event rises.
pEvent(Object) A referrence 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 use the Pm.StringCodeFrom method.

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 PmiItem.onKeyPress or PmPanel.onKeyPress event.
Example:
The following example is in the format 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
Dim aList, sViewer
If pEvent.Action = 0 And pEvent.Ctrl And Not pEvent.Shift And Not pEvent.Alt Then
  Select Case pEvent.Code
    Case 83 ' Key S
      Pm.AppStop
    Case 73 ' Key I
    Case 80 ' Key P
      Pm.WndLogon true
    Case 79 ' Key O
      Pm.WndLogoff true
    Case 71 ' Key G
      aList = Pm.FindViewers("groups:menu;viewers:panel;","", "columns:path,title;")
      sViewer = Pm.SelectionDialog(aList, "", "$.text('sys','panelsName')", "size:300,350;autoselect:1;")
      If Pm.IsValid(sViewer) Then Pm.GetActiveWorkspace().OpenView sViewer, "target:main;", ""
    Case 65 ' Key A
      aList = Pm.FindViewers("groups:menu;viewers:alarm_state;","", "columns:path,title,alstate3,alstate2,alstate1,alhoot;")
      sViewer = Pm.SelectionDialog(aList, "", "$.text('sys','alarmsName')", "size:500,350;autoselect:1;")
      If Pm.IsValid(sViewer) Then Pm.GetActiveWorkspace().OpenView sViewer, "target:main;", ""
    Case 69 ' Key E
      aList = Pm.FindViewers("groups:menu;viewers:event;","","columns:path,title;")
      sViewer = Pm.SelectionDialog(aList, "", "$.text('sys','eventsName')", "size:500,350;autoselect:1;")
      If Pm.IsValid(sViewer) Then Pm.GetActiveWorkspace().OpenView sViewer, "target:main;", ""
  End Select
End If
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice