I have a TEdit
in a Delphi VCL form app (contained in a TFrame
instance, if it matters). After a user indicates they are finished editing, by clicking elsewhere on the form, the caret and focus remain on this control until I click on another control, which then takes the focus. However, I want the TEdit
to loose focus regardless of where the user clicks. I expect I can use ActiveControl := nil
to end focus on the selected control, but I am uncertain where to invoke it.
What I want is for the focus to leave the selected control without necessarily having to transfer it to another control. I could end focus in the form's OnClick
event, but that will not work if the user selects any of the other controls (also contained in frames) on my form, since the form's OnClick
event is not triggered. It seems inelegant and tedious to provide separate OnClick
events for each additional item on the form.
What is the global solution to achieve this behavior?