Tree View - KeyPress Event

Fired when a key is pressed on the keyboard

Member of Tree View (PRIM_TRVW)

Parameters

Name Type Data Type Description
KeyCode *Input Enumeration The key that was pressed
Char *Both Unicode String Character that was pressed
IsAltDown *Input Boolean Is the Alt key down?
IsControlDown *Input Boolean Is the Ctrl key down?
IsShiftDown *Input Boolean Is the Shift key down?
Handled *Both Boolean Set to true to stop the key being processed automatically

Details

The KeyPress event is fired when a key is pressed.
 
If the key pressed was a character, the Char parameter will contain the character and the KeyCode parameter will contain the value "IsChar".
 
If the key pressed was one of a number of control keys such as arrows, function keys, Home or End, etc., the KeyCode will contain the name of the key, and Char will be empty. Autocomplete or F2 will provide a complete list of available values.
 
Mainstream actions requiring key processing are handled automatically in LANSA.
 
For Enter key processing use the Enter event or a button with a ButtonDefault property of True
 
To hide input for passwords you can use an Edit control with and specify the PasswordChar, or use a field with an input attribute of ND.
 
To interrupt entry to complete a value use the AutoCompleting event on a field.
 
KeyPress is provided for completeness and is unlikely to be required for most development purposes.

Example

This example shows the values output by a KeyPress event.
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Height(469) Left(190) Top(223) Width(686) Clientwidth(670) Clientheight(430) Layoutmanager(#TableLayout1)
 
   Define_Com Class(#PRIM_TBLO) Name(#TableLayout1)
   Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) Displayposition(1) Parent(#TableLayout1)
   Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) Displayposition(1) Parent(#TableLayout1)
   Define_Com Class(#PRIM_TBLO.Item) Name(#ListViewItem1) Column(#Column1) Manage(#ListView) Parent(#TableLayout1) Row(#Row1)
 
   Define_Com Class(#PRIM_LTVW) Name(#ListView) Columnbuttonheight(19) Componentversion(2) Displayposition(1) Fullrowselect(True) Keyboardpositioning(SortColumn) Left(0) Parent(#COM_OWNER) Showsortarrow(True) Tabposition(1) Top(0) Height(430) Width(670)
   Define_Com Class(#PRIM_LVCL) Name(#LVCL1) Displayposition(1) Parent(#ListView) Source(#xDemoAlpha128) Width(33) Captiontype(Caption) Caption('KeyCode')
   Define_Com Class(#PRIM_LVCL) Name(#LVCL2) Displayposition(2) Parent(#ListView) Source(#xDemoCaption) Captiontype(Caption) Caption('Character') Width(26)
 
   Evtroutine Handling(#ListView.KeyPress) Keycode(#KeyCode) Char(#Char)
 
      #xDemoAlpha128 := #KeyCode
      #xDemoCaption := #Char
 
      Add_Entry To_List(#ListView)
 
   Endroutine
 
End_Com
 

See also

All Component Classes

Technical Reference

LANSA Version 15, April 2020