gICAPI.SetFocus()

The gICAPI.SetFocus() function must be used to request the focus to the runtime system.

Purpose of gICAPI.SetFocus()

The tabbing order and focus management is controlled by the runtime system and the dialog code (NEXT FIELD).

If your WEBCOMPONENT field receives an event that requests the focus, you must first perform a gICAPI.SetFocus() call to determine if the program can put the focus in the field.

Focus acknowledgment

The gICAPI.SetFocus() function is used in conjunction with the gICAPI.onFocus() callback function. If the program can give the focus to the field, gICAPI.onFocus() is called with true as parameter. The gICAPI.onFocus() is not called if one of the following conditions is true:

  • the current field cannot release the focus because it does not satisfy constraints (VERIFY, data type conversion, and so on),
  • the dialog code logic prevents focus change (AFTER FIELD ..., NEXT FIELD, etc).

A good practice is to define an internal flag, to know if your WEBCOMPONENT field has gained the focus.

Example

The following code example uses the gICAPI.SetFocus() function to get the focus from the runtime system:

var has_focus;

var onICHostReady = function(version) {

    has_focus = false;

    ...

    gICAPI.onFocus = function(polarity) {
        has_focus = polarity;
        if (has_focus) {
            $('textarea#value').focus();
        }
    }

    $("textarea#log").on("focus", function() {
        gICAPI.SetFocus();
    });

    ...

};