Recent

Author Topic: OpenDialog and mouse event  (Read 768 times)

hedgehog

  • Jr. Member
  • **
  • Posts: 65
OpenDialog and mouse event
« on: June 16, 2025, 09:43:17 am »
I noticed strange behavior of OpenDialog (Lazarus 4 and Win64)

1) Call OpenDialog.
2) Place the file selection window above the form.
3) Select the file by double-clicking

After that MouseMove event will occur for form, and Shift = [ssLeft]

Is this normal behavior?

ASerge

  • Hero Member
  • *****
  • Posts: 2439
Re: OpenDialog and mouse event
« Reply #1 on: June 17, 2025, 06:22:51 pm »
Is this normal behavior?
Not confirm. Windows 7, x64, Lazarus 4.0, fpc 3.2.2. After double-clicking on the file above the form, no mouse event occurred.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11456
  • Debugger - SynEdit - and more
    • wiki
Re: OpenDialog and mouse event
« Reply #2 on: June 17, 2025, 07:37:19 pm »
Win 10 => yes, get the mouse-move.

Not sure, if that is right or wrong.

The dialog closes on the 2nd mouse down.
I.e. you can do (on a filename in the open dlg)
- left mouse down
- left mouse up
- left mouse down (and keep down)

And the dialog will close.

Now you have
- the button down
- the dlg closed
- the mouse over the form

Since the dlg no longer exists, any mouse-capture that it might have had, would be gone. So mouse event go - as they normally do - to the control below the mouse.


Well, and yes, there is a mouse move. Even if the mouse did not move since (and during) the button up/downs.
But the last mouse pos for the form was over the button, and now it is no longer over the button. That apparently is reported as a move. (and catching it in the debugger, it appears that it was generated by the OS / by Windows)

If I position the form such as,
- that the file open dialog will open above it,
- and that one of the filenames will be over the area of the form
And I position the mouse cursor where that filename will be...
And then
- I lift the mouse off the table, so there will be no movement
- I trigger the dialog open via keyboard (so the mouse can be kept were it is)
- I double click the filename (that will have appeared below the mouse)
  and optionally keep the button down on the 2nd click...
=> then there is no move being reported.

But of course, if I keep the button down, and start moving the mouse, then there will be.




hedgehog

  • Jr. Member
  • **
  • Posts: 65
Re: OpenDialog and mouse event
« Reply #3 on: June 19, 2025, 08:06:03 am »
I forgot to say that I have Windows 10.
My application uses mouse control.
And when using OpenDialog I noticed some incorrect behavior.

I think OpenDialog should not pass mouse events

jcmontherock

  • Sr. Member
  • ****
  • Posts: 300
Re: OpenDialog and mouse event
« Reply #4 on: June 19, 2025, 11:37:35 am »
It's work fine in Windows 11
Windows 11 UTF8-64 - Lazarus 4.0-64 - FPC 3.2.2

 

TinyPortal © 2005-2018