trigger loseFocus (Field)

Trigger that defines what happens after a user successfully leaves a field in a form component.

Declaration: trigger loseFocus
Applies to: Field
Activation: Activated when the cursor is successfully moved out of the field that has focus as a result of user action or $prompt. For details, see Trigger Activation
Default behavior: None
Behavior upon completion: If $status is less than 0, the user cannot leave the field.

If the field has not been modified, the terminal beeps. If the field has been modified, the terminal does not beep.


This trigger is typically used for such things as calculations and running another form. It is activated whenever the active path changes. You can use the ProcScript function $fieldendmod to check whether the field has been modified by the user. (This function is only valid in the loseFocus trigger. )

For example, in a field containing money data, you might want to calculate the sales tax and assign that to the relevant field. Use $fieldendmod to first check the modification status of the field, saving unnecessary processing if the data has not been modified.

If you want to change the order in which Uniface prompts for fields, use the next and previous triggers rather than using $prompt in this trigger.

The loseFocus trigger is one of a group of event completion triggers (including leaveModifiedKey and valueChanged) that work in combination with the validation triggers to handle all the processing that should take place when a user modifies the active path. In general, the event completion triggers are used for user interface and calculation functionality; the validation triggers are intended to handle data validation and error trapping.

Trigger Activation

Before the loseFocus trigger can be activated, all data validation checks must have completed without error; a negative return value prevents the user leaving the field.

The loseFocus trigger is not activated by the setocc statement.

In an interactive session of a desktop application, this trigger is activated regardless of whether or not the user has modified the field.


The following example automatically recalculates the value of a computed field whenever one of the fields in the computation is modified. The example ensures that the internal field ELAPSED_TIME is recalculated whenever the user modifies the START_TIME or END_TIME fields. The ProcScript to do this is contained in the loseFocus triggers of START_TIME and END_TIME:

trigger loseFocus ; of END_TIME


trigger loseFocus ; of START_TIME

Related Topics