[Lazarus] I can't exit this component

Marc Weustink marc at dommelstein.nl
Sat Mar 30 20:20:29 CET 2024


The onenter is indeed fired when the control gets focus. However if you show a dialog in that event, the control loses focus and gets it again when the dialog is closed, resulting in a loop.
In general it is  bad coding to have much logic in onenter/onleave events 

I once was confronted with an app which checked if you didn't leave an empty mandatory edit. If so, the app set the focus back to the control you left. But if you navigated to the next empty mandatory edit it ran into an endless loop focussing both edits 

Marc

On March 30, 2024 1:50:14 PM GMT+01:00, "Arí Ricardo Ody via lazarus" <lazarus at lists.lazarus-ide.org> wrote:
>I was thinking that OnEnter would refer to receiving focus. If it responds
>to mouse movement then it is explained.
>
>I changed the logic to use the OnClick event in the component. Then it
>worked.
>
>I see now that it was a lack of knowledge on my part.
>
>Thank you very much.
>
>On Fri, Mar 29, 2024 at 9:03 AM Werner Pamler via lazarus <
>lazarus at lists.lazarus-ide.org> wrote:
>
>> Am 29.03.2024 um 12:09 schrieb Arí Ricardo Ody via lazarus:
>> > procedure TfrmGeraString.tedtNomArqMicEnter(Sender: TObject);
>> The "Enter" in this method name indicates that you assigned the event
>> handler to the OnEnter event of something (a button maybe). This means
>> that whenever the mouse is moved over this button ("enter") the event
>> fires. Usuall dialogs are displayed only when a "click" occurs, and this
>> responsibility is in the OnClick event of the button.
>> --
>> _______________________________________________
>> lazarus mailing list
>> lazarus at lists.lazarus-ide.org
>> https://lists.lazarus-ide.org/listinfo/lazarus
>>


More information about the lazarus mailing list