If you've ever researched methods for determining which element of an array the user clicked on in LabVIEW, you have probably noticed that LabVIEW provides a method for converting pixel coordinates to a row-column pair for tables, but no such method exists for arrays.
The Determine Clicked Array Element Index VI converts pixel coordinates to row-column pairs for 1D or 2D arrays - enabling you to easily determine which element of an array the users of your application clicked on.
Many of the currently available methods for determining which element of an array the user clicked on in LabVIEW have some shortcomings or limitations, so I decided to see if I could develop a method for accomplishing this that would meet two primary criteria:
The Determine Clicked Array Element Index VI enables you to easily determine which element of an array the users of your application clicked on.
The Determine Clicked Array Element Index VI distribution includes a fully-documented and functional example VI that demonstrates how to use the Determine Clicked Array Element Index VI.
and create an interface that is similar to the glyph selector in the NI Icon Editor in an instant! | ![]() |
---|
Run the included example VI to see how you can use the Determine Clicked Array Element Index VI in your own applications.
Readme file for Determine Clicked Array Element Index VI
Description
The Determine Clicked Array Element Index VI takes the coordinates of click input and determines the index of the array element that the user clicked on.
NOTE: Proper operation of the Determine Clicked Array Element Index VI requires that a caption has been created for the array of interest by following the numbered steps below:
Application Software
LabVIEW 2010 or later.
Driver Software
None.
Extracting the files
The Determine Clicked Array Element Index VI is supplied as a zip archive containing all required items.
Additional Information
Additional information related to the use and operation of the Determine Clicked Array Element Index VI may be accessed via:
Developed by
Mark Ridgley
|
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Fab piece of work! Many thanks.
It's crazy that LabVIEW doesn't support this function natively. Not a problem any more though 🙂
Jon
Thanks for posting this. However, I can't get it to run since on both downloads, it looks like the vi "Determine Clicked Array Element Index - Determine Array and Scrollbar Properties.vi" is missing. Maybe I'm missing something?
Kyle
Hello,
I downloaded both the LabVIEW 2010 and 2011 versions, extracted them and found the Determine Array and Scrollbar Properties.vi at the following path:
..Distribution\Determine Clicked Array Element Index 201x\_Subs.
Please ensure that you have the latest latest downloads as indicated by the "File Added..." portion of the download filename. Give it another try and let me know if that solves the issue.
Thanks,
Mark Ridgley
Hi Mark,
I found the issue. It turned out that the directory where I extracted the files into already had a long name and that combined with some of the long file names in the distribution caused a few of the files to clip off at the end, including the extensions. I extracted to the C:\ level and it worked fine. Thanks!
Kyle
It doesn't seem to work with LabVIEW 2012. I have checked and quadruple checked that the array has a caption (and a label). Even the array elements have captions - but I still get an error telling me to add a caption when I click the array. Is there an updated version for 2012, or is there some other issue?
-Marcus
Hi Marcus,
Thanks for downloading this code. I'm sorry to hear that you are having trouble with it.
I did a few tests to see if I could recreate what you are seeing. I used LabVIEW 2012 to open the LabVIEW 2011 version of the usage example VI that is included in the distribution. Everything loaded fine and the VI showed that it needed to be saved (as expected). I closed the VI and selected Save All when prompted. I re-opened the usage example VI, ran it and everything worked as expected.
Next, I built a new VI from scratch following the instructions in the block diagram of the usage example VI and everything worked as expected again.
I'm unable to duplicate the issue that you have described. Would you be able to send me a copy of the VI that you are having trouble with so that I can continue looking into this? If so, you can send the VI to the email address that you'll find in the VI description of the usage example VI.
I hope to hear from you soon.
Mark Ridgley
Hi Mark,
Thank you so much for sharing.
-Sagar
Amazing,
Thank you so much
-Danish
Thanks Mark! I adapted to work with right click shortcut menu cmds!
That's beautiful !!
This needs updating for Silver and NXG styles (or any array control with modified border sizes) as the hardcoded values only work with Modern controls (and possibly Classic ones).