TWinControl.CanFocus function
Is this control allowed to receive the focus when parent form is visible?
Declaration
function CanFocus: Boolean; virtualDescription
Checks if the control can get focus when parent form is visible, i.e. if all its parents except the form are visible and enabled.
A possible usage:
if FormFoo.EditBar.CanFocus then FormFoo.ActiveControl := FormFoo.EditBar;
CanFocus returns True even if the parent form is not actually visible,
and a subsequent SetFocus call could throw an exception. Use
CanSetFocus in this case.
See also
An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.
