gotFocus

gotFocus(cntrl: Control input);         (Form)

gotFocus(control: control-type input);  (Control)

The gotFocus event occurs when a control receives the focus, either by a user action such as tabbing to or clicking the object or by changing the focus in logic using the setFocus method. A copy of this event is first sent to the form.

This event is not returned for a form, as a form does not have focus unless there are no input controls. Use the activate event instead.

Typically, a gotFocus event method specifies the actions that occur when a control first receives the focus. For example, by attaching a gotFocus method to each control on a form, you can guide the user by displaying brief instructions or status bar messages.

You can also provide visual cues, by enabling, disabling, or showing other controls that depend on the control that has the focus.

An object can receive the focus only if its enabled and visible properties are set to true.

When focus is gained by a control, a gotFocus event is also sent to the form, identifying the control that gained focus. The form itself never gains the focus, but this event (in conjunction with the lostFocus event) provides a centralized place where all focus change events can be monitored in a similar way to the keyDown, keyPress, and keyUp events of the Form class.