05-21-2025 06:11 AM
This is a small project to simulate a touch pad. Basically everything is working. The sliders can be moved with the cursor keys or mouse. Clicking the scroll wheel will activate the touch pad and move the mouse to the position equivalent to the last values of the sliders.
I have zipped the whole project for testing.
My question: In the "Pane": Mouse Down, True case (larger one), there are two contants: 12 and 80. I cannot see why these are required to position the mouse correctly. The values do not seem to correspond to a border height or anything. Maybe someone could have a look and find the reason.
I have saved the folder in Labview 2019 format.
Many thanks.
Mark
Solved! Go to Solution.
05-21-2025 06:13 AM
Hi Mark,
@vtiu wrote:
there are two contants: 12 and 80. I cannot see why these are required to position the mouse correctly. The values do not seem to correspond to a border height or anything. Maybe someone could have a look and find the reason.
According to the comment in the block diagram those constants are related to the position of the 2D Picture control/indicator labelled "Mousepad"…
05-21-2025 06:18 AM
Wow, that was quick! Try setting the constants to 0 and see where the mose goes. It moves the cursor to a different position and adjusts the sliders accordingly.
Am I missing something?
Mark
05-21-2025 06:25 AM - edited 05-21-2025 06:26 AM
Hi Mark,
@vtiu wrote:
Try setting the constants to 0 and see where the mose goes.
There is some weird math in the subVI, and there is no good explanation for that.
The VI in your ZIP has different code than shown in the image in your 1st message…
Where should the "mouse" go to? What is the desired target position?
@vtiu wrote:
It moves the cursor to a different position and adjusts the sliders accordingly.
And your VI does not "adjust the sliders accordingly"! What are these sliders good for?
05-21-2025 06:36 AM
The VI in your ZIP has different code than shown in the image in your 1st message… - I posted a partial screenshot to show where the constants are. My original post and my 2023 version are the same - sorry????
There is some weird math in the subVI - You mean the Slider2Pad(SubVI)?
The point is to move the sliders to a certain position. Then click the mouse wheel. The mouse cursor should move to the equivalent position on the "pad". For example, move the up/down slider to say 1800 and the left/right to 2000. Clicking the scroll wheel should move to the position lining up with the two sliders without the values changing.
Without the two constants it does not work.
Regards
Mark
05-21-2025 07:00 AM
Hi Mark,
@vtiu wrote:
The VI in your ZIP has different code than shown in the image in your 1st message… - I posted a partial screenshot to show where the constants are. My original post and my 2023 version are the same - sorry????
I'm sorry, I was opening the wrong VI…
@vtiu wrote:
Without the two constants it does not work.
You need to handle differences between LabVIEW screen positions and Windows mouse position.
Atleast it seems to be a fixed offset as for me (virtual machine, Win10, taskbar moved to left side of the screen) your VI works with the same values…
05-21-2025 07:11 AM
I'm sorry, I was opening the wrong VI… - You had me worried for a second there 🙂
The position of the front panel is taken into account. As is the position of the 2D picture on the panel.
All I have done is to calculate the coordinates in the picture based on the sliders using y=mx+c.
Effectively, the X-axis goes from 500 to 2500 which equates to the picture left and width. Same with the Y-axis. This is detailed in the video here
https://www.youtube.com/watch?v=Zl5GW35dUjc at roughly 27 minutes.
The point is to control two servo motors as per video.
Regards
Mark
05-21-2025 08:13 AM - edited 05-21-2025 08:21 AM
The correct way to get mouse coordinates of a picture is with the mouse property. No need for any tweaks:
All that remains is the scaling between pad size and slider range.
The event should be mousepad...mouse down. Typically you don't care about mouse coordinates outside the picture (i.e. "pane"). This will greatly simplify your code!
(On a side note, it would be great to have that cluster as an event data node. Could be an idea....)
05-21-2025 10:14 AM - edited 05-21-2025 10:50 AM
See if this can give you some general ideas...
(Note: I uploaded a new VI recently, so make sure you have the correct one)
05-21-2025 11:12 AM