Recent

Author Topic: How to simulate mousedown,mousemove and mouseup events in code?  (Read 638 times)

Josh

  • Hero Member
  • *****
  • Posts: 1270
How to simulate mousedown,mousemove and mouseup events in code?
« on: December 10, 2022, 09:51:51 am »
Hi

i am trying to create a help routine in a windows app so that if F1 is pressed it will move the mouse over a specified control (tbutton), call the mousedown event (for grab) of the button, then call mousemove (to drag it) and finally a mouseup event (to complete the drag/drop).

the control if used normally has the code for drag/drop etc, so the code is to emulate the mouse movement.

Any ideas how to accomplish this cross platform, note the mouse cursor does not have to move I will animate that with a Larger Mouse image.

« Last Edit: December 10, 2022, 10:03:23 am by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: How to simulate mousedown,mousemove and mouseup events in code?
« Reply #1 on: December 10, 2022, 10:05:42 am »
... then call mousemove (to drag it) ...
Calling MouseMove does not drag a control.
MouseMove is called in response to user mouse action.
What you want to accomplish requires use of the
https://wiki.lazarus.freepascal.org/MouseAndKeyInput

unit.
« Last Edit: December 10, 2022, 10:10:36 am by howardpc »

Josh

  • Hero Member
  • *****
  • Posts: 1270
Re: How to simulate mousedown,mousemove and mouseup events in code?
« Reply #2 on: December 10, 2022, 10:37:02 am »
Hi

Thanks for that, tested the example and looks like it will do,

Immediate problem is that I also use bgracontrols, which stops me adding the requirement to project inspector, duplicate dependency error...

I have my own code that drags the control, and this is controlled by the mousemove event.

Just looking a documention linked to, and the underlying code, it  looks like it does not support Mac cocoa.
« Last Edit: December 10, 2022, 11:04:59 am by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: How to simulate mousedown,mousemove and mouseup events in code?
« Reply #3 on: December 10, 2022, 11:13:50 am »
Quote
  it  looks like it does not support Mac cocoa.
See this thread:https://forum.lazarus.freepascal.org/index.php/topic,47830.msg343398.html#msg343398
« Last Edit: December 10, 2022, 11:15:39 am by howardpc »

 

TinyPortal © 2005-2018