GetFocus

Description

Determines the control that currently has focus.

Syntax

GetFocus ( )

Return value

GraphicObject. Returns the control that currently has focus. Returns an invalid control reference if an error occurs.

Use the IsValid function to determine whether GetFocus has returned a valid control.

Examples

These statements set which_control equal to the datatype of the control that currently has focus, and then set text_value to the text property of the control:

GraphicObject which_control
SingleLineEdit sle_which
CommandButton cb_which
string text_value
 
which_control = GetFocus()
 
CHOOSE CASE TypeOf(which_control)
 
CASE CommandButton!
    cb_which = which_control
    text_value = cb_which.Text
 
CASE SingleLineEdit!
    sle_which = which_control
    text_value = sle_which.Text
 
CASE ELSE
    text_value = ""
END CHOOSE

See also

IsValid

SetFocus