Sign in Join
FPDoc Onlineexperiment

TWinControl.CanSetFocus function

Member of TWinControlpublicIn unit Controls

Is this control allowed to receive the focus?

Declaration

pascal
function CanSetFocus: Boolean; virtual

Description

Checks if the control can receive focus, i.e. if all its parents are visible and enabled.

A possible usage:

if MyControl.CanSetFocus then
   MyControl.SetFocus;

CanSetFocus should be preferred over CanFocus if used in CanSetFocus/SetFocus combination because it checks also if the parent form can receive focus and thus prevents the "cannot focus an invisible window" LCL exception.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.