Apply events in your application
- Last Updated: January 16, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
You have already seen cases where a procedure causes an event to fire “artificially” by using
the APPLY statement. In the CustOrders procedure, each
button trigger has to APPLY the VALUE-CHANGED event to
the Order browse to get it to run the internal procedure to display
related data for the Order, such as this code for the
Next button trigger:
|
The APPLY statement causes whatever trigger is currently active for the
event and object to fire. Unlike the ON statement, you must place the
name of the event in quotation marks in an APPLY statement, if it is a
literal value. This makes it possible to APPLY the value of a character
variable instead. In this way, you can define a CHARACTER variable, assign it a value of
an event name during program execution, and then use that value in an
APPLY statement, adding flexibility to your programming. For
example:
|
By contrast, ABL must know the event for an ON statement at compile time
to prepare the trigger properly. For this reason the event name cannot be a variable, so
you can specify it with or without quotation marks in the ON
statement.
|
The LAST-KEY keyword is a built-in function that returns the value of
the last keystroke the user pressed. Every time you enter a letter into the first
fill-in field, cFillFrom, the ANY-PRINTABLE trigger
fires which, as its name suggests, responds to any printable character typed on the
keyboard, and this trigger retrieves that keystroke and applies it to the other fill-in
field, cFillTo. So you can apply not just the standard events but even
keyboard characters to an object like a fill-in field, if is enabled for input.
This figure shows the effect of typing Text into
cFillFrom.