Knowledge Base

Article ID: 1332 | Category: Project Setup | Type: FAQ | Last Modified: 8/27/2015

Scripts for processing interface events

Description

For what interface events can I use scripts? What is the difference between scripts handling interface events and event handlers that are used for customizing processing? When may shell event handlers be useful?

Solution

There are 4 ways to configure station interfaces in ABBYY FlexiCapture 10:

  1. Toolbar and menu settings
  2. Keyboard shortcut customization
  3. Customization of colors of interface elements (e.g. the frames that enclose selected fields in the Document Definition editor or the frames and fill-in color of fields with errors and warnings)
  4. Scripts that handle interface events

Event handlers are the most flexible interface customization tool available in ABBYY FlexiCapture 10: they can be used to implement user-defined commands in workstations, make stations behave in certain ways when specific conditions are met, customize the interface and much more. For example, a script that handles interface events can be used to forbid a Verification Station operator to close a document before a specific field has been filled in.

These scripts handle interface events. They are triggered when a specific event happens to a specific element, just like event handlers for processing stages.

The following events can be handled by scripts:

Scripts that process interface events are specified for every stage tool separately, i.e. a separate set of event handlers is specified for every stage. If a script that handles the On Activate Document event is added to the verification stage, this script will only be triggered when documents are opened during the verification stage. If, for example, a document is opened during the exceptions stage, this script will not be triggered.
This is the main difference between scripts that process interface events and event handlers for customizing processing: the later are not limited to a processing stage and are executed whenever the event they handle takes place, e.g. if a script that handles the Before Page Delete event has been specified, it will be executed when the operator tries to delete a page during the verification stage, and when the operator tries to delete a page during the exceptions stage. For more information about Events Handlers see this article.

You can find a list of objects that you can use in scripts in the following help article: Appendix >> Using scripts in ABBYY FlexiCapture 10 >> Scripts for customizing interface >> Objects. All of these objects are available to read and write.

Interface event scripts can access ControllerInterop objects, but access rights depend on the objects state. The current document state is returned by the DocumentState() method of the ITaskWindow interface. If the document state is DS_Opened, then the ControllerInterop objects of the document are available to read and write. For other states, the objects of ControllerInterop are read-only.

Interface event scripts can access interface elements (task bars, menus and windows). These scripts can be used to customize a station's interface. For example, a script that handles the On open document event can be used in a Verification Station to specify document viewing parameters (enable/disable the black-and-white mode, zoom in or out, specify the position of the image editor relative to the Form window, etc.) customize the Form (change the sizes of the window and text), and specify which types of errors (rule, format and assembly errors, unmatched region errors) will be displayed in the corresponding window. Interface event scripts can also be used to customize task bars (add or remove buttons).

Note that when a station is closed, all changes made to its interface by scripts will not be saved and will revert to their defaults. So let's say, for example, you added an On open document script that specifies that for batch type 1, only rule errors should be displayed in the errors pane of the Verification Station, and did not add any interface event handlers for any other batch types. When the Verification Station operator that has processed a type 1 batch during the previous session opens the station again and begins processing a batch of another type, the errors pane will display all possible error types.

How to create a script handling an interface event

As we have said earlier, interface event scripts are specified separately for every stage tool. To add an interface event script, go to the Stage Tools tab of the project properties dialog, select a stage to which you wish to add an event handler and open its settings (double-click the name in the list or click the Edit... button).

Click the Add Event button and the Add Event dialog will open. Select the desired event from the drop-down list and enter the script text.

The InterfaceEvents.rar archive contains examples of projects that use interface event handlers.

515 people think this is helpful.
Was this information helpful to you?