trigger getFocus (Field)

Trigger that reacts to a field getting focus in a Form component. It is usually used for user interactions such as prompting the user with a hint message, or modifying the way a field is displayed.

Declaration: trigger getFocus
Applies to: Field in Form components.
Activation: Activated when the field gets focus as a result of user actions, structure editor functions, or ProcScript commands.
Default behavior: None
Behavior upon completion: None


One of the primary uses of this trigger is to visually indicate the current field (for example using $fieldproperties or fieldvideo) or to display useful information when the cursor enters the field.

You should not use ProcScript instructions that change the current occurrence (for example, setocc, retrieve, or clear). The loseFocus trigger is usually a better place for this kind of action.

Trigger Activation

The getFocus trigger of a field can be activated in several ways:

  • When a mouse click positions the cursor within the field.
  • When the scroll bar is used to move through multiple occurrences.
  • When a structure editor function (such as ^FIELD) positions the cursor within the field.
  • When the active path changes by way of a ProcScript instruction such as $prompt, setocc, and so on.

The getFocus trigger is not activated when the cursor is positioned using arrow keys (character mode).

If the field that previously had focus was in another occurrence, Uniface first activates the entity's getFocus trigger and then the field's getFocus trigger.

When the scroll bar is used to move through multiple occurrences of an entity, the getFocus trigger for the first field in each new current occurrence is activated. If the previous occurrence did not have focus when the scroll bar was first used, the getFocus trigger in the first field of that occurrence is activated before the trigger in the new current occurrence.

Displaying a Message

The following example uses a message/hint statement to display a helpful message:

trigger getFocus 
   message/hint "5-digit correspondence code"
end; getFocus

Related Topics