Using Events For Interaction

<< Click to Display Table of Contents >>

Navigation:  Interactive Documents >

Using Events For Interaction

Previous pageReturn to chapter overviewNext page

As explained in the previous section, Fields are used to exchange data between your application and Controls. You can set Field values before displaying an interactive form and you can retrieve values from the Fields, for example when the preview is closed.

However, this is a very basic interaction between the user and your application.

To allow a much more sophisticated interaction between the user and your application, VPE sends several events (notification messages) to your application. These events will inform you about actions that are currently performed by the user. Some events allow to control, whether a specific  action of the user may take place or not.

The Events:

Event: AfterControlEnter

A Control received the focus.

Normally, this event is sent if the user presses the Tab or Backtab key, or clicks with the mouse onto a control. This event can be used to re-format the content of a control.

Event: RequestControlExit

The user wishes to remove the focus from the currently focused Control.

In response to this event your application can evalute the value of the Control and decide, whether the current value is valid and the Control may lose the focus or not.

Event: AfterControlExit

The currently focused Control lost the focus.

Normally, this event is sent if the user presses the Tab or Backtab key, or clicks with the mouse onto another control. When receiving this message, it is possible for you to force the focus to be set explicitly to a specific control by calling SetFocusControlByName() or SetFocus(). It is also possible to enable and disable other controls of the current form while processing this event.
In addition this event can be used to re-format the content of a control.

Event: AfterControlChange

A Control changed its value, i.e. the content of a Control was edited by the user or the value of an associated Field was changed by code.

Evaluating this event means that your application is informed about every single keystroke or mouse-click, which modifies a Control's content.

If you are working with Fields that are associated with controls - as recommended - your application should not take care of this event.

This is one of the few events where CloseDoc() may be called while processing the event.
The event is not fired, if you set the value of a Control by code.

Event: AfterFieldChange

A Field (not a control!) changed its value, because the associated Control was edited by the user or the content of any associated Control was changed by code.

This event is very interesting, because a Field will change its value each time the user makes a change. Evaluating this event means that your application is informed about every single keystroke or mouse-click, which modifies a Control's content.

This is one of the few events where CloseDoc() may be called while processing the event.
The event is not fired, if you set the value of a Field by code.

 

NOTE: If you change the value of a Control by code, the AfterControlChange event is not fired. But if the Control is associated with a Field, the event AfterFieldChange is fired.
Vice versa, if you change the value of a Field by code, the AfterFieldChange event is not fired, but any Controls associated with the Field will fire the event AfterControlChange.

The demo program "VPE Interactive Demo" (vpeidemo.exe) shipped with VPE gives a very good overview about the event structure. It shows what events are fired in response to specific user actions. To run the demo, choose "Demos | Enhanced Template Processing" from the menu.