Chapter 29. VirtualKeyCodes Class

Table of Contents
Methods of the VirtualKeyCodes Class
Symbolic Names for Virtual Keys

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"

Methods of the VirtualKeyCodes Class

Instances of the VirtualKeyCodes class implement the methods described in the following sections.

VCode

>>-aVirtualKeyCodes~VCode(--keyname--)-------------------------><


The VCode method returns the decimal value of a symbolic key name.

Arguments:

The only argument is:

keyname

The symbolic key name. See Symbolic Names for Virtual Keys for a list of key names.

Return value:

The decimal value of the symbolic key name. If the symbolic name is not found, 255 is returned.

KeyName

>>-aVirtualKeyCodes~KeyName(--vcode--)-------------------------><


The KeyName method returns the symbolic key name of the specified hexadecimal code.

Arguments:

The only argument is:

vcode

The hexadecimal code of the key.

Return value:

The symbolic key name of the specified code.

Example:

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_NEW