Event handlers
- Last Updated: May 30, 2019
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
.NET supports an event model for classes. Like ABL class-based objects, .NET objects define events as members. An ABL application can respond to any .NET event using an ABL event handler. These event handlers are associated with specific .NET events. .NET forms and controls fire events when an action occurs. As a result all subscribed handlers get called.
ABL allows you to subscribe and unsubscribe event handler methods
or internal procedures to .NET events. You can use the Subscribe( ) method
on a .NET event of a particular .NET class instance
to subscribe event handlers written in ABL. .NET supports multiple
subscribers attached to one event. Normally two parameters are passed to
the event handler—the object firing the event and an object that
provides event-specific arguments as properties.
In this example, the FormObjectRef object subscribes
to the owner of the Load event, passing it the name
of the event handler, the FormObjectRefLoad( ) method:
|
You can use the Unsubscribe( ) method
to detach an event handler from a control.
A .NET event handler can be either a method in a class (.cls)
or an internal procedure. The main difference between using methods
and internal procedures as .NET event handlers is that ABL
verifies method event handler signatures at compile time (using
strong typing), and verifies internal procedure event handler signatures
at run time.