The methods of the VirtualKeyCodes class can be used for all objects of the WindowsProgramManager and WindowObject classes. These classes inherit from the VirtualKeyCodes class. The VirtualKeyCodes class cannot be used as a standalone class.
The VirtualKeyCodes class requires the class definition file WinSystm.cls:
::requires "WinSystm.cls"
Instances of the VirtualKeyCodes class implement the methods described in the following sections.
>>-aVirtualKeyCodes~VCode(--keyname--)-------------------------><
The VCode method returns the decimal value of a symbolic key name.
The only argument is:
The symbolic key name. See Symbolic Names for Virtual Keys for a list of key names.
The decimal value of the symbolic key name. If the symbolic name is not found, 255 is returned.
>>-aVirtualKeyCodes~KeyName(--vcode--)-------------------------><
The KeyName method returns the symbolic key name of the specified hexadecimal code.
The only argument is:
The hexadecimal code of the key.
The symbolic key name of the specified code.
The following example deletes or inserts an item in a tree view depending on the selected key:
::method OnKeyDown_IDC_TREE
use arg treeId, key
curTree = self~GetTreeControl(treeId)
/* if the Delete key is pressed, delete the selected item */
if self~KeyName(key) = "DELETE" then
curTree~Delete(curTree~Selected)
else
/* if the Insert key is pressed, simulate pressing the New button */
if self~KeyName(key) = "INSERT" then
self~IDC_PB_NEWSymbolic Names for Virtual Keys shows the symbolic names and the keyboard equivalents for the virtual keys used by Object Rexx:
Table 10-8. Symbolic Names for Virtual Keys
| Symbolic Name | Mouse or Keyboard Equivalent |
|---|---|
| LBUTTON | Left mouse button |
| RBUTTON | Right mouse button |
| CANCEL | Control-break processing |
| MBUTTON | Middle mouse button (three-button mouse) |
| BACK | BACKSPACE key |
| TAB | TAB key |
| CLEAR | CLEAR key |
| RETURN | ENTER key |
| SHIFT | SHIFT key |
| CONTROL | CRTL key |
| MENU | ALT key |
| PAUSE | PAUSE key |
| CAPITAL | CAPS LOCK key |
| ESCAPE | ESC key |
| SPACE | SPACEBAR |
| PRIOR | PAGE UP key |
| NEXT | PAGE DOWN key |
| END | END key |
| HOME | HOME key |
| LEFT | LEFT ARROW key |
| UP | UP ARROW key |
| RIGHT | RIGHT ARROW key |
| DOWN | DOWN ARROW key |
| SELECT | SELECT key |
| EXECUTE | EXECUTE key |
| SNAPSHOT | PRINT SCREEN key |
| INSERT | INS key |
| DELETE | DEL key |
| HELP | HELP key |
| 0 | 0 key |
| 1 | 1 key |
| 2 | 2 key |
| 3 | 3 key |
| 4 | 4 key |
| 5 | 5 key |
| 6 | 6 key |
| 7 | 7 key |
| 8 | 8 key |
| 9 | 9 key |
| A | A key |
| B | B key |
| C | C key |
| D | D key |
| E | E key |
| F | F key |
| G | G key |
| H | H key |
| I | I key |
| J | J key |
| K | K key |
| L | L key |
| M | M key |
| N | N key |
| O | O key |
| Q | Q key |
| R | R key |
| S | S key |
| T | T key |
| U | U key |
| V | V key |
| W | W key |
| X | X key |
| Y | Y key |
| Z | Z key |
| NUMPAD0 | Numeric keypad 0 key |
| NUMPAD1 | Numeric keypad 1 key |
| NUMPAD2 | Numeric keypad 2 key |
| NUMPAD3 | Numeric keypad 3 key |
| NUMPAD4 | Numeric keypad 4 key |
| NUMPAD5 | Numeric keypad 5 key |
| NUMPAD6 | Numeric keypad 6 key |
| NUMPAD7 | Numeric keypad 7 key |
| NUMPAD8 | Numeric keypad 8 key |
| NUMPAD9 | Numeric keypad 9 key |
| MULTIPLY | Multiply key |
| ADD | Add key |
| SEPARATOR | Separator key |
| SUBTRACT | Subtract key |
| DECIMAL | Decimal key |
| DIVIDE | Divide key |
| F1 | F1 key |
| F2 | F2 key |
| F3 | F3 key |
| F4 | F4 key |
| F5 | F5 key |
| F6 | F6 key |
| F7 | F7 key |
| F8 | F8 key |
| F9 | F9 key |
| F10 | F10 key |
| F11 | F11 key |
| F12 | F12 key |
| F13 | F13 key |
| F14 | F14 key |
| F15 | F15 key |
| F16 | F16 key |
| F17 | F17 key |
| F18 | F18 key |
| F19 | F19 key |
| F20 | F20 key |
| F21 | F21 key |
| F22 | F22 key |
| F23 | F23 key |
| F24 | F24 key |
| NUMLOCK | NUM LOCK key |
| SCROLL | SCROLL LOCK key |