[Lazarus] Is TForm.LastActiveControl working correctly?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Is TForm.LastActiveControl working correctly?

Free Pascal - Lazarus mailing list
Hi,

I'm using Lazarus 2.0.10 on Windows10 and I'm trying to make use of
TForm.LastActiveControl.
My form has a TButtonpanel with HelpButton and CancelButton visible.
There is an Actionlist with 2 actions, each with a Shortcut (F1 and
Esc). The form has 3 TLabeledEdit fields.
My purpose is that the field that has the focus keeps that (I do that in
the FormOnActivate routine) after calling Help by clicking on the
HelpButton.  But that is not the case, the focus is placed on that
HelpButton.
I added some debug lines to check the value of ActiveControl and
LastActiveControl in an OnEnter and OnExit routine for each field. The
result is that every action I take (use tab of mouse to activate another
control) gives the same result: ActiveControl and lastActiveControl
allways point to the same control.

Is this a bug or is my understanding of lastActiveControl wrong?

--
mvg
Frans van Leeuwen
M 06-51695390


--
Deze e-mail is gecontroleerd op virussen door AVG.
http://www.avg.com

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Is TForm.LastActiveControl working correctly?

Free Pascal - Lazarus mailing list
On Sun, Dec 6, 2020 at 1:22 PM frans via lazarus <[hidden email]> wrote:
ActiveControl and lastActiveControl always point to the same control.

Is this a bug or is my understanding of lastActiveControl wrong?

That is how it is implemented. It is set to ActiveControl unless ActiveControl is Nil or a TCustomForm.
  if (FActiveControl<>nil) and not (FActiveControl is TCustomForm) then
    FLastActiveControl := FActiveControl;

I did not know about LastActiveControl. What is the use of it? TScreen class seems to have it, too.
Anyway, you can easily keep track of the previous ActiveControl in your code yourself.

Regards,
Juha


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus