How You Can Set the Focus Behavior
Every active field has a focus behavior attribute (FocusBehavior) that controls the behavior of the field with respect to the input focus. Specifically, the focus behavior setting determines:
• Whether the field can have the input focus
• Whether the field is in the tabbing sequence (that is, whether the end user can tab to the field)
• What happens to the field that currently has the input focus when the end user clicks the field or tabs to the field
You can use the Frame Editor's Property Inspector to set the initial value for a field's focus behavior. You can also use a frame's 4GL script to change the focus behavior as the frame is running.
The following describes each focus behavior setting and its effect:
FT_TABTO
Specifies that the field accepts the input focus and is part of the tabbing sequence. The field takes the input focus when the user clicks the field or tabs to the field. For more information, see
Tab Sequencing.
Clicking the field or tabbing to a field with this focus behavior may affect the field that currently has the input focus. For example, suppose that a frame has entry fields A and B. Suppose also that the focus behavior of field B is FT_TABTO. If the user clicks field B (or tabs to field B) when field A has the input focus, the following events occur in order:
1. A SetValue event for field A (if the user has changed the data in field A)
2. An Exit event for field A
3. An Entry event for field B
The SetValue event generated for field A enables the script to validate data in field A before the input focus switches to field B. If the data in field A is not correct, the program can execute a resume statement to prevent the remaining events from occurring. In this case, field A retains the input focus. (For descriptions of these events, see Events in the Language Reference Guide.)
Note: FT_TABTO is the default focus behavior for a single-line entry field.
FT_TAKEFOCUS
Specifies that the behavior is the same as for FT_TABTO, except that the field is not part of the tabbing sequence. The field can, however, take the input focus. Clicking the field causes the same sequence of events as for FT_TABTO.
Note: FT_TAKEFOCUS is the default behavior for multiline entry fields.
FT_SETVALUE
Specifies that the field is not part of the tabbing sequence and does not accept the input focus. Clicking the field causes a SetValue event for the field that has the input focus. This setting is useful for fields such as an OK button that performs data validation.
For example, suppose that a frame has an entry field, E, and a button field, OK. If the user clicks the OK button while field E has the input focus, the following events occur:
• A SetValue event for field E (if the data in field E has changed since it took the input focus)
• A Click event for field OK
This sequence of events enables the program to check the data in field E before processing the OK button. In this case, there is no Exit event for field E because field E does not lose the input focus.
FT_NOSETVALUE
Specifies that the field cannot take the input focus and is not part of the tabbing sequence. Clicking the field does not change the input focus and does not force a SetValue event for the field that has the input focus. This setting is useful for fields such as a Cancel button or a Help button where it is not necessary to check the data in the field that has the input focus.
Note: If a field's current bias conflicts with its focus behavior, the bias attribute retains control. For example, if a field's current bias is FB_VISIBLE and its focus behavior is FT_TABTO, the user cannot tab to the field.