RectControl.SetFocus

From Xojo Documentation

Method

RectControl.SetFocus()

Supported for all project types and targets.

If applicable, sets the focus to the RectControl. KeyDown events are directed to the control.

Notes

If the control cannot get the focus on the platform on which the application is running, SetFocus does nothing. The SetFocus method of the Window class or the ClearFocus method can be used to remove the focus from the control that currently has the focus, leaving no control with the focus.

On the Mac you need Full Keyboard Access turned on in System Preferences (Keyboard->Shortcuts) in order to manually set focus to non-text controls.

Sample Code

The following example sets the focus to TextField1. If another control has the focus when this line is executed, then the user sees that TextField1 gets the focus.

TextField1.SetFocus