Recent

Author Topic: [SOLVED] Focus on mouse-hover: How to avoid this?  (Read 577 times)

Pastim Codar

  • Newbie
  • Posts: 5
[SOLVED] Focus on mouse-hover: How to avoid this?
« on: September 12, 2023, 09:35:07 am »
I'm working with Lazarus 2.2.6 + dfsg2 - 2 + b1 on Linux (Kali Linux, 6.4.0-kali3-amd64, GTK2/3).

Problem description:

I have an application which opens one main form. It has a button which opens another form with a little calculator. When I start the application and press the calculator button all works fine: The calculator window is on top of the main window, the calculator has the focus and the mouse-pointer is on the calculator, too.

When I move the mouse-pointer out of the boundaries of the calculator and hover over the main window, this main window gets the focus and the calculator disappears behind the main window. And all this just by mouse-hovering!

Remarks:

On my Linux notebook I do not use the general focus on mouse-hover policy! I always click on windows to activate them. The behavior of the Lazarus program is exactly as if I had activated focus on mouse-hover, but I have not.

To mitigate the problem I have entered this procedure:

Code: Pascal  [Select][+][-]
  1. procedure TMeanCalculator.FormCreate(Sender: TObject);
  2. begin
  3.   Self.formstyle := fsStayOnTop;
  4. end;    

But this only helps in so far as the calculator window does not disappear. The focus stealing problem is not solved by this.

What I want:

The problem should not occur at all! When the mouse-pointer leaves the calculator window nothing should happen as long as I do not click on anything else.

Question:

Is there a Lazarus option (which I could not find) or a hidden configuration item which prevents the problematic behavior? Can anyone explain possible reasons for this?

Thanks a lot, guys!
« Last Edit: September 13, 2023, 02:11:38 pm by Pastim Codar »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 1720
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Focus on mouse-hover: How to avoid this?
« Reply #1 on: September 12, 2023, 10:19:23 am »
Can anyone explain possible reasons for this?
Your provided Line of code works perfect here so I assume that the error is somewhere else.
How about to make a minimalistic demo that show your described error? (mainform, button that open second form, your error must happen)
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

cdbc

  • Hero Member
  • *****
  • Posts: 722
    • http://www.cdbc.dk
Re: Focus on mouse-hover: How to avoid this?
« Reply #2 on: September 12, 2023, 01:50:10 pm »
Hi
Does "HotTrack" pertain to this issue, if so, set it to false.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6

Pastim Codar

  • Newbie
  • Posts: 5
Re: Focus on mouse-hover: How to avoid this?
« Reply #3 on: September 12, 2023, 05:22:28 pm »
Your provided Line of code works perfect here so I assume that the error is somewhere else.

It only works perfect in so far, as the calculator window stays on top. But I said: It mitigates the error, it doesn't resolve it: When I hover from the calculator window onto the main window the calculator window still loses focus. And I couldn't find a workaround yet.

Pastim Codar

  • Newbie
  • Posts: 5
Re: Focus on mouse-hover: How to avoid this?
« Reply #4 on: September 12, 2023, 05:24:16 pm »
Does "HotTrack" pertain to this issue, if so, set it to false.

Sorry, but what is "HotTrack"? I found descriptions of this property but can't find an object which has this property in my project. Where do I have to look for it?
« Last Edit: September 12, 2023, 05:42:55 pm by Pastim Codar »

Pastim Codar

  • Newbie
  • Posts: 5
Re: Focus on mouse-hover: How to avoid this?
« Reply #5 on: September 13, 2023, 02:11:01 pm »
I found the error after a lot of work and testing:

The main window uses a TChart. The phenomenon which caused my problems was caused by the AutoFocus property of the chart which was set. When I avoid to hover over the chart the problem doesn't occur.

I was not aware that the AutoFocus property is even active when another window has the focus: The chart grabs the focus even when its own form doesn't have the focus. That's a bit strange from my point of view.

 

TinyPortal © 2005-2018