From 11:00 PM CST Friday, May 9th - 3:00 PM CST Saturday, May 10th, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CST Friday, May 9th - 3:00 PM CST Saturday, May 10th, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example shows how to determine which element of an array a user has clicked on the front panel.
Description
This example shows how to determine which element of an array a user has clicked on the front panel. It uses an even structure to determine when a user has clicked on an array element. Then using the coordinates of the mouse cursor and the dimensions of the array, it calculates which element was clicked on.
Requirements: LabVIEW 2012 (or compatible). Hardware: none.
Steps to Implement or Execute Code:
Additional Information or References:
**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.
Thank you for sharing...works great!
This does not work correctly if you have a label or caption on displayed on the array. To fix this, use the "Master Bounds Rect" property to replace the "Position" and "Bounds" properties. The Top and Left values come right out of the "MastRect" cluster, then you will have to calculate the Height and Width values using the "MastRect" Bottom and Right values.
You do not need to wire anything to the count terminal for the For Loop since your already auto-indexing. Just delete it.
I think it's relevant to point out we can get the reference for the array element and get some of its properties including the value, not the index though... I guess we can't get the references array because the number of elements will change in run-time.
I think I can't attach the VI file but here's the block diagram.
Here is a less complicated version:
It accounts for the possibility of the array being scrolled away from 0,0, and disregards any labels that may be showing.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
CoastalMaineBird's answer was a perfect solution for the problem I had. I just modified it to work for a 1-D array and to work from references so I could have it as a subVI. I'd Kudo's him if I could but his message somehow doesn't allow itself to be kudo'd.