ON CHANGE block

The ON CHANGE block can be used to detect that a field changed by user input. The ON CHANGE block is executed if the value has changed since the field got the focus and if the modification flag is set.

The ON CHANGE block can be used in INPUT, INPUT ARRAY and CONSTRUCT dialogs.

For editable fields defined as EDIT, TEXTEDIT or BUTTONEDIT, the ON CHANGE block is executed when leaving a field, if the value of the specified field has changed since the field got the focus and if the modification flag is set for the field. You leave the field when you validate the dialog, when you move to another field, or when you move to another row in an INPUT ARRAY. However, if the text edit field is defined with the COMPLETER attribute to enable autocompletion, the ON CHANGE trigger will be fired after a short period of time, when the user has typed characters in.

For editable fields defined as CHECKBOX, COMBOBOX, DATEEDIT, DATETIMEEDIT, TIMEEDIT, RADIOGROUP, SPINEDIT, SLIDER or URL-based WEBCOMPONENT (when the COMPONENTTYPE attribute is not used), the ON CHANGE block is invoked immediately when the user changes the value with the widget edition feature. For example, when toggling the state of a CHECKBOX, when selecting an item in a COMBOBOX list, or when choosing a date in the calendar of a DATEEDIT. Note that for such item types, when ON CHANGE is fired, the modification flag is always set.

   ON CHANGE order_checked -- Defined as CHECKBOX
      CALL setup_dialog(DIALOG)
Note: If both an ON CHANGE block and AFTER FIELD block are defined for a field, the ON CHANGE block is executed before the AFTER FIELD block.

When changing the value of the current field by program in an ON ACTION block, the ON CHANGE block will be executed when leaving the field if the value is different from the reference value and if the modification flag is set (after previous user input or when the touched flag has been changed by program).

In an INPUT or INPUT ARRAY, the field value change is related to value of the variable bound to the field. In a CONSTRUCT dialog, the field value change is related to the input buffer / displayed value.

Note: When using the NEXT FIELD instruction, the comparison value is reassigned as if the user had left and reentered the field. Therefore, when using NEXT FIELD in ON CHANGE block or in an ON ACTION block, the ON CHANGE block will only be invoked again if the value is different from the reference value. This prevents field validation in ON CHANGE blocks; you must do validations in AFTER FIELD blocks and/or AFTER INPUT blocks.