Lazarus
Programming => General => Topic started by: pcurtis on October 20, 2020, 07:12:51 am
-
Hi All,
How can I detect if the mouse is within the forms area?
OnMouseLeave is triggered if the mouse moves over another component on the same form.
Thanks in advance.
-
Maybe that would help: https://forum.lazarus.freepascal.org/index.php?topic=16843.0
-
Thanks.
-
Don't know if it's mentioned in that thread, but you could also try the OnMouseEnter and OnMouseLeave events of the form.
-
Hi!
OnMouseEnter and OnMouseLeave are only triggered if the mouse is inside the area of the form.
If the mouse enters or leaves that area the event is NOT triggered.
Winni
-
The attached demo shows (on Windows - did not test others...) that the OnMouseEnter/Leave events fire whenever the mouse enters/leaves a form or a control, but only the top-most control is considered. This means that when a control covers the form fully (like the memo in the demo after the checkbox has been checked) these events of the form do not fire any more when the mouse is moved into/out of the form horizontally. Only the OnUserInput event of the ApplicationProperties fire whenever the mouse is inside the form, it is some kind of "super-OnMouseMove".