To download NI software, including the products shown below, visit ni.com/downloads.
Overview: In this VI the front panel control/indicator is moved while the mouse is moving and not after the mouse button has been released.
Description:
This example is based on the following example: Drag and Drop Controls and Indicators on Front Panel.
The difference is that this example moves the front panel control/indicator while the mouse is moving and not after the mouse button has been released.
This uses an event structure with a "Mouse Move" event to track the position of the mouse and adjust the coordinates of the control/indicator accordingly. This adjustment only occurs when the mouse has been clicked on the control/indicator.
Requirements: LabVIEW 2012 (or compatible). Hardware: none.
Steps to Implement or Execute Code:
1. Run the VI.
2. Click on the Boolean control.
3. Move the mouse.
4. Release mouse.
5. Stop the VI.
Additional Information or References:
This example is currently set up to have the Boolean control adjust such that the center of the control moves to the location of the mouse.
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
This looks incredible. I've been looking to do something like this to allow users to customize their own printed tickets by dragging and dropping from a list of fields.
Can u upload a version for 8.5 or earlier please?
If you do convert please do so to at least 8.0 thx
I copied this techinque just to be sure it worked from scratch as well as from the download. Ran into some strange behavioe (bug?) if the boolean's label is turned on and the boolean is small (like the default boolean, 17 x 17). The mouse up event doesn't register! Ha!
Hi joshuatree,
Sorry it's taken me so long to do this, but I've uploaded a version saved in LabVIEW 8.5.
Hi Pablop,
Thanks for pointing that out. That is some strange behavior and it seems only to happen when the label is visible. I'm going to look into it a little bit further and file a bug report if necessary. Thanks for bring this to my attention!
It's because of the offset applied between the mouse position and the position at which you set the object. The object's position is the top left as it appears on the screen (including any visible label and caption). The extent is the distance right and down any part of the object reaches. Add an offset of half of these to the origin and you arrive at a point to the right of the (small) LED and beneath the label, but not actually ON any part of the screen object. Therfore when you mouse up it won't register as an event on the object because the mouse isn't over any part of the object.
As a work around you could terminate the move on 'mouse up' on the pane rather than the object
Also you need to remember that you don't recognise a mouse up if you move the mouse off the pane, so add 'mouse leave' on the pane to the event that stops the object moving.
As another thought, disallow right click menus on the object (Advanced -> Real-Time shortcut menu -> Disable) and only start the moving on a right mouse down (In the event for enabling movement, only set the boolean if button=2). That way the left click actions still work normally.