QGrid
![]() |
![]() |
QG_SetEventHandler(areaRef; methodName; eventMask):errorCode | |||
![]() |
areaRef | Longint | QGrid area reference |
![]() |
methodName | String31 | Callback method name |
![]() |
eventMask | Longint | Supported events |
![]() |
error | Longint | Error result |
Installs an event handler method for the QGrid area, and specifies the event types that the area will intercept.
Parameter areaRef is the QGrid area reference. If areaRef is not a valid QGrid area reference, qg_paramErr error is returned.
Parameter methodName is the name of the method that will handle user events. Passing an empty string in methodName for a QGrid area will remove any previously installed event handler. Parameter eventMask is not used in this case and can be omitted.
Parameter eventMask specifies the types of events that will be intercepted by the event handler. The eventMask parameter is constructed by combining (with addition or bitwise "or") any of the following constants:
qg_TrapClickEvent | 0x00000010 | Intercept click events |
qg_TrapDoubleClickEvent | 0x00002000 | Intercept double click events |
qg_TrapDropEvent | 0x00010000 | Intercept drop events |
Structure of the Event Handler Method
The event handler typically contains a case statement where each event type is individually handled. The event handler must comply with the following calling interface:
-> | $1 | area | Longint | Reference to the QGrid area |
-> | $2 | eventType | Longint | Event type |
-> | $3 | eventData | Longint | Event data |
<- | $0 | resultCode | Longint | Result code, currently set to zero (0) |
QGrid defines the following constants for eventType:
qg_ClickEvent | 4 | Same as 4D's On Clicked |
qg_DoubleClickEvent | 13 | Same as 4D's On Double Clicked |
qg_DropEvent | 16 | Same as 4D's On Drop |
Example
` Declare QG_CALLBACK as the event handler method for area xGrid C_LONGINT($eventMask) ` set mask to intercept all types of events $eventMask:=qg_TrapClickEvent | qg_TrapDoubleClickEvent | qg_TrapDropEvent $err:=QG_SetEventHandler(xGrid;"QG_CALLBACK";$eventMask) `--------------------------------------------------------------------- ` method QG_CALLBACK ` Simple QGrid callback routine C_LONGINT($1) ` areaRef C_LONGINT($2) ` event Type C_LONGINT($3) ` event Data C_LONGINT($0) ` result Case of : ($2=qg_ClickEvent) ALERT("Single click on cell "+String($3)) ` param $3 holds the clicked cell index : ($2=qg_DoubleClickEvent) ALERT("Double click on cell "+String($3)) ` param $3 holds the double-clicked cell index : ($2=qg_DropEvent) ALERT("Drop event before cell "+String($3)) ` param $3 holds the drop position End case |