Function GetEventReader() Foundation
Implements the default READ behavior of a single Get object for the event code returned by AppEvent().
GetEventReader( <oGet> ) --> NIL
The return value of GetEventReader() is always NIL.
GetEventReader() implements the default READ behavior of individual Get objects and handles mouse and keyboard events. Events are handled by calling GetHandleEvent(). In addition, GetEventReader() takes care of the data validation before and after input.
For compatibility reasons, the keyboard is read by Inkey() by default, and the mouse is not active. In order to handle events in the Get system using GetEventReader(), SetMouse(.T.) must be called before the first call to READ or ReadModal(). Alternatively, GetEventReader() can be activated by calling GetEnableEvents(.T.). Note that GetEnableEvents(.T.) only causes GetEventReader() to be used for handling data input. It does not activate the mouse, so without SetMouse(.T.), no mouse events will be handled by GetEventReader().
User-defined Get readers can be used to replace the default reader of the Xbase++ Get system by specifying a function call within a code block that replaces GetEventReader() as the input handler. This code block is assigned to the instance variable oGet:reader. If the instance variable contains a code block, the code block is evaluated and its function executed with the Get object as its parameter, replacing GetEventReader().
// The example implements a user-defined Get reader
// when using AppEvent() instead of Inkey(). No special
// character input with READ is allowed. German umlauts
// and the " " are translated to two characters in the
// reader NoUmlauts(). All other events are handled
// by the default mechanism GetHandleEvent().
#include "Get.ch"
**************
PROCEDURE Main
LOCAL cName1 := Space(20), cName2 := Space(20)
SetMouse(.T.) // Activates mouse
@ 8,10 SAY "Input without umlauts and "
@ 10,10 SAY "First name:" GET cName1 ; // Defines Get reader
SEND reader := {|o| NoUmlauts(o) }
@ 12,10 SAY " Last name:" GET cName2 ;
SEND reader := {|o| NoUmlauts(o) }
READ
RETURN
***************************
PROCEDURE NoUmlauts( oGet )
LOCAL bBlock, cChar, nEvent, mp1, mp2, oXbp
IF GetPreValidate( oGet ) // Prevalidate GET
oGet:setFocus() // Set input focus
bBlock := {|o,n1,n2| ; // Translate to two
GetHandleEvent(o,n1),; // characters in the code
IIf( o:typeOut, ; // block
NIL, ;
GetHandleEvent(o,n2) ) }
DO WHILE oGet:exitState == GE_NOEXIT
IF oGet:typeOut // No editable characters
oGet:exitState := GE_ENTER // to the right of the cursor
ENDIF
// Read events
DO WHILE oGet:exitState == GE_NOEXIT
nEvent:= AppEvent( @mp1, @mp2, @oXbp, 0 )
cChar := Chr(nEvent)
DO CASE // Translate special
// characters
CASE cChar == " "
Eval( bBlock, oGet, Asc("A"), Asc("e") )
CASE cChar == " "
Eval( bBlock, oGet, Asc("O"), Asc("e") )
CASE cChar == " "
Eval( bBlock, oGet, Asc("U"), Asc("e") )
CASE cChar == " "
Eval( bBlock, oGet, Asc("a"), Asc("e") )
CASE cChar == " "
Eval( bBlock, oGet, Asc("o"), Asc("e") )
CASE cChar == " "
Eval( bBlock, oGet, Asc("u"), Asc("e") )
CASE cChar == " "
Eval( bBlock, oGet, Asc("s"), Asc("s") )
OTHERWISE
GetHandleEvent( oGet, nEvent, mp1, mp2, oXbp )
ENDCASE
ENDDO
IF ! GetPostValidate( oGet )
oGet:exitState:= GE_NOEXIT // Post-validation failed
ENDIF
ENDDO
oGet:killFocus() // Set back input focus
ENDIF
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.