Event handler is a Fore unit. Event handler provides a possibility to set actions when a particular event occurs enhancing functionalities of the workspace.
NOTE. Setting event handler is available only in the desktop application.
To create an event handler, select the Event Handler > Create > Create Fore Unit item on the Home ribbon tab.
An event handler can also be created in the Event Handling dialog box. Select the Event Handler > Setup item on the Home ribbon tab. In the dialog box that opens select the Create > Create Fore Unit item.
After executing those actions, the standard dialog box to select object in object navigator opens:
The created unit or assembly contain ready structure with all workspace events.
To connect event handler, select the Event Handler > Set Up item on the Home ribbon tab:
In the dialog box that opens select unit and class where an event handler is located:
Select a Fore unit containing a class with the event handler in the Unit box. One can select an object in the drop-down list or click the icon and enter object name. To remove the object from the box, click the button.
In the Class box select class containing event handler. One can select a class in the drop-down list or click the icon and enter class name. To remove the class from the box, click the button.
To set up and edit events in the development environment, click the Open in the Development Environment button.
Executing the example requires that the unit contains the Eventclass class.
Add links to the Ui and Workspace system assemblies.
Class EventsClass: WorkspaceEvents
Public Sub OnBeforeOpenWorkspace(Args: IUiWorkspaceCancelEventArgs);
Begin
Winapplication.InformationBox("Message before opening workspace");
Args.Cancel := False;
End Sub OnBeforeOpenWorkspace;
End Class EventsClass;
As a result of event handler work, the specific message is displayed before opening the workspace.
See also: