Language Reference Guide : Events : Exit Event
 
Share this page          
Exit Event
The Exit event is triggered when the user leaves a field that currently has the input focus. This event is triggered before the current field actually loses the input focus. It is also triggered whether or not the user changed any data in the field. Therefore, to execute an event only when the user actually changes data (for validation purposes, for example), use the SetValue event instead.
This event has the following syntax:
on exit [fieldname]
fieldname is optional if you specify this event in a field script.
The field must have a focus behavior of either FT_TABTO or FT_TAKEFOCUS to receive an Exit event.
The following attributes of the FrameExec class can be used in the Exit event block:
TriggerField
Specifies the field that is being exited.
The value for this field must match the value for the OriginatorField.
OriginatorField
Specifies the field specified in the initial on exit statement.
The value for this field must match the value for the TriggerField.
TargetField
Specifies the field to which the user is intending to move the input focus
InputFocusField
Specifies that this field is undefined at the beginning of the event block.
When the block is completed, the input focus moves to this field. By setting this value in the Exit event block, you can control where the input focus will be when the event block completes.
Use the CurFrame system variable to access these attributes. For more information, see FrameExec Class.
Usage: The Exit event is defined for all scalar fields. This event is not defined for menu fields, shape fields, or composite fields.
If the field has the appropriate focus behavior and an Exit event is defined for that field, then the event is triggered when the user moves the input focus to another field. Clicking a field that has a focus behavior of FT_SETVALUE or FT_NOSETVALUE does not move the input focus from the current field and, consequently, does not trigger an Exit event for that field.
The Exit event can control the tab order of fields by checking the value of the field that is being exited and setting InputFocusField to the field where you want to resume. For example, assume that your form has four fields, one called testfield (an integer) and the others called field1, field2, and field3. Suppose (depending on the value in testfield) you want to move to either field2 or field3 when you exit testfield. You could use the following event block to perform this task:
on exit testfield =
begin
    if testfield = 2 then
        CurFrame.InputFocusField = field(field2);
        resume;
endif;
if testfield = 3 then
        CurFrame.InputFocusField = field(field3);
        resume;
    endif;
    /* Any other values will fall through to the
    ** standard sequence, which means that
    ** OpenROAD moves the user to the next field
    ** in the tabbing sequence
    */
end
This code moves the input focus to field2 or field3 if testfield has a value of two or three, respectively, even if the user clicks with the intention of going to another field.
Because the Exit event is not defined for composite fields, you cannot use it to detect exits from table field columns. You can use only the ChildExit event to do so or to provide some generic operations for execution when the user leaves any field on a form. For more information about this event, see ChildExit Event.
More information:
InputFocusField Attribute
OriginatorField Attribute
TargetField Attribute
TriggerField Attribute