4D Write v14WR ON EVENT |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D Write v14
WR ON EVENT
|
WR ON EVENT ( area ; event ; method ) | ||||||||
Parameter | Type | Description | ||||||
area | Longint |
![]() |
4D Write area | |||||
event | Longint |
![]() |
Event code | |||||
method | String |
![]() |
Method to execute | |||||
The WR ON EVENT command installs method as the method to be called whenever the event described by event occurs in area. Events are passed directly to method before being handled by 4D Write.
If area equals 0, method becomes the default event method for all 4D Write areas until the database is closed. If an area has a specific event method installed, that method is called instead of the default.
In the event parameter, pass a value indicating the event to intercept. You can use one of the following predefined constants, located in the WR Events theme:
Constant | Type | Value | Comment |
wr on key | Longint | 0 | Key down (including arrow keys, returns, tabs…) |
wr on double click | Longint | 1 | A double click |
wr on single click | Longint | 2 | A single click |
wr on triple click | Longint | 3 | Three clicks |
wr on right click | Longint | 4 | A click with the right mouse button |
wr on activate | Longint | 5 | 4D Write area activated or deactivated |
wr on printing | Longint | 7 | Printing document |
wr on ruler | Longint | 8 | Ruler modification |
wr on compute references | Longint | 9 | Dynamic references modified |
wr on close | Longint | 10 | 4D Write area or window closed |
wr on drag | Longint | 11 | An object is dragged |
wr on drop | Longint | 12 | An object is dropped |
wr on timer | Longint | 13 | End of a timer cycle |
To activate method for all events, pass -1 in event.
When called, method receives seven parameters that describe the state of area at the time of the event. You must explicitly type these parameters using compiler directives. The following table describes the parameters received by method:
Parameter | Type | Description |
$1 | Long integer | 4D Write area |
$2 | Integer | Shift key |
$3 | Integer | Alt (Windows), Option (Mac OS) |
$4 | Integer | Ctrl (Windows), Command (Mac OS) |
$5 | Integer | Event type |
$6 | Integer | Changes depending on event type |
$0 | Long integer | If method returns a value |
$1 returns the long integer that is the area ID where the event took place. $2, $3, and $4 describe whether a specific modifier key was depressed at the time of the event. If the value equals 0, the key was not pressed. If the value equals 1, the key was pressed. $5 returns the event type. $6 varies depending on the type of event.
Method Variables and the Event Parameter ($6)
Note: If you filter all characters, operations may slow down considerably since the method will be called for each keystroke.
In the following examples, some actions are executed depending on the type of event:
`Form method:
If(Form event=On Load)
WR ON EVENT(Area;wr on key;"ProcName")
`Call for all keystrokes
WR ON EVENT(Area;wr on activate;"ProcName")
`Check for area status
DISABLE MENU ITEM(2;1)
`Disable menu item "Change font"
WR SET AREA PROPERTY(Area;wr timer frequency;54000)
`Timer event every 15 min
WR ON EVENT(Area;wr on timer;"ProcName")
`Setting up auto-save
End if
`ProcName method:
Case of
:($5=wr on key)
`Intercepts the keystrokes
If($6=199)|($6=200)
`ASCII codes corresponding
BEEP
$0:=1
Else
`Leave the event to 4D Write
$0:=0
End if
:($5=wr on activate)
`Intercept change in status of area
If($6=0)
`If the area is inactive
DISABLE MENU ITEM(2;1)
Else
ENABLE MENU ITEM(2;1)
End if
:($5=wr on timer)
`Every 15 min
$DocName:="C:\\Temp\\Docs\\TheArea.4W7"
WR SAVE DOCUMENT(TheArea;$DocName;"4WR7")
End case
Product: 4D Write
Theme: WR Utilities
Number:
89174
Modified: 4D Write 2004.1
WR Get on event method
WR ON ERROR
4D Write Language ( 4D Write v11.6)
4D Write Language ( 4D Write v12)
4D Write Language ( 4D v13)
4D Write Language ( 4D Write v14)
4D Write Language ( 4D Write v14 R2)
4D Write Language ( 4D Write v14 R3)
4D Write Language ( 4D Write v14 R4)