Which form item has the focus?

Identify what element of the current form has the focus.

Dialog control blocks such as BEFORE INPUT, BEFORE DISPLAY, BEFORE ROW, BEFORE FIELD, AFTER FIELD, AFTER ROW, AFTER DISPLAY, AFTER INPUT are executed when the focus enters or leaves a field or a group of fields controlled by a sub-dialog. By design, these control blocks implicitely identify which form element has the focus: When code executing in a BEFORE FIELD cust_id block, we are in the cust_id field.

Sometimes, you need to identify which form element has currently the focus, in a context different for a control block such as BEFORE FIELD, especially with a DIALOG block, which controls several parts of a form. For example, when several lists are controlled by multiple DISPLAY ARRAY sub-dialogs, you may need to know which is the current list in the context of a dialog-level ON ACTION block.

To get the name of the current form item, use the DIALOG.getCurrentItem() method. This method is the replacement of the former fgl_dialog_getfieldname() built-in function. It has been extended to return identifiers for fields, lists, or actions identifiers.

DIALOG ATTRIBUTES(UNBUFFERED)
   DISPLAY ARRAY p_orders TO orders.*
     ...
   END DISPLAY
   DISPLAY ARRAY p_items TO items.*
     ...
   END DISPLAY
   ...
      IF DIALOG.getCurrentItem() == "items" THEN
         ...
      END IF
   ...
END DIALOG