LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

register mouse events

Hello,

I just wanted to ask if there is an easy way to obtain mouse events (such as mouse down, scroll wheel etc.) within an event structure (as it is possible with the keyboard). Now I'm using a while loop to continuously acquire the mouse state. It would be much more convenient however if I could use events to detect the mouse state.

Thanks a lot in advance for any help!
0 Kudos
Message 1 of 9
(3,789 Views)
Hi,

      As there are states of the mouse itself available in the Event Structure, so you can detect the state of the mouse if it is "Mouse down" or it is "Mouse up" and same thing for the right mouse click, so that is the simple way to take the mouse events in the Event structure i think.

Thanks,
Nishant
Message 2 of 9
(3,776 Views)
My nugget is just about this (with some tricks)

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 9
(3,773 Views)
Hi Nishant,

thanks for your answer! Within the event structure, I just found under 'pane' events for mouse down or up, however not for left or right mouse key. Is that what you meant or do you know of another option to detect mouse events within an event structure (the scroll-wheel)?

Thank you very much!
0 Kudos
Message 4 of 9
(3,774 Views)
Hi,

             In the event test case if you go to the event dialog box and click on the "This VI" option in the left pan, it will show you the options in the right pan for that, in those options the options of mouse buttons are available. Hope this helps.

Please explain your exact requirement, then it will be easy to give you solution for anybody.

Thanks,
Nishant
0 Kudos
Message 5 of 9
(3,766 Views)
Hi Nishant,

unfortunately, there is no option for mouse events under <this vi>, only keyboard. Do I have to install an additional package?

Regarding my application:
With the mouse scroll-wheel I want to interactively scale analog output data, i.e.: when I scroll in one direction data for an analog output task is multiplied by a specific value and given to the AO write vi (upscaled), when I scroll in the other direction the data is divided (downscaled).
When I keep the right mouse button pressed and  the mouse is moved, an offset is being added to the data corresponding to the length of the mouse move (with the right button pressed).
When the left button is pressed and the mouse is moved, a rotation operation is being done on the data.
I have this implemented using the initialize mouse vis within a continuously running while loop, now I'm rewriting our application and I just realized that it would be very nice, if I could use mouse events just the same as keaboard events can be monitored within an event structure.

Hope I was clear and thank you very much for any help!


0 Kudos
Message 6 of 9
(3,751 Views)


@WernerGobel wrote:
Hi Nishant,

unfortunately, there is no option for mouse events under <this vi>, only keyboard. Do I have to install an additional package?

Regarding my application:
With the mouse scroll-wheel I want to interactively scale analog output data, i.e.: when I scroll in one direction data for an analog output task is multiplied by a specific value and given to the AO write vi (upscaled), when I scroll in the other direction the data is divided (downscaled).
When I keep the right mouse button pressed and  the mouse is moved, an offset is being added to the data corresponding to the length of the mouse move (with the right button pressed).
When the left button is pressed and the mouse is moved, a rotation operation is being done on the data.
I have this implemented using the initialize mouse vis within a continuously running while loop, now I'm rewriting our application and I just realized that it would be very nice, if I could use mouse events just the same as keaboard events can be monitored within an event structure.

Hope I was clear and thank you very much for any help!




Look for pane (or control events) they have mouse events.

I haven't tested the scroll wheel, looking at your code I would register for the mouse move event as soon as a mouse down event is happening as I have shown in my nugget.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 7 of 9
(3,732 Views)
Hi Ton,

thanks a lot for your answer. I found the mouse down/move events under the pane menu, though I don't really know how to distinguish between left/right mouse button. Regarding your very interesting nugget, do you know how I can independently from a picture object or from any kind of object set the events?

Thanks a lot!
0 Kudos
Message 8 of 9
(3,708 Views)
The button data in the event structure shows which button is used (Primary mouse button (most of the time left) is 1, secondary is 2),

I don't know how to track the scroll wheel

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 9 of 9
(3,699 Views)