Minh Pham Posted December 22, 2008 Report Share Posted December 22, 2008 Hi guys, I just wondering that is anyone in here success capturing the event (eg. mouse down or double click) from an element within an array. (index returned prefered) As LabVIEW doesnt have this option, it does have the Mouse Co-ordinate values returned which can be used but it is not the optimal way of doing this i guess, you still have to figure out which item within the array is clicked/double-clicked and return the index so you can process a certain task for that item (eg. change the value, or pop-up msg). Any help is appreciated, Regards, Quote Link to comment
Francois Normandin Posted December 22, 2008 Report Share Posted December 22, 2008 QUOTE (Minh Pham @ Dec 21 2008, 05:39 PM) Hi guys,I just wondering that is anyone in here success capturing the event (eg. mouse down or double click) from an element within an array. (index returned prefered) As LabVIEW doesnt have this option, it does have the Mouse Co-ordinate values returned which can be used but it is not the optimal way of doing this i guess, you still have to figure out which item within the array is clicked/double-clicked and return the index so you can process a certain task for that item (eg. change the value, or pop-up msg). Any help is appreciated, Regards, If you don't worry about datatype (i.e if you use strings), you could use a listbox. Listboxes have a method "Point to Row" that inputs the mouse coordinates and outputs index. As far as I know, I don't think Arrays have a method to do that. Otherwise, if all your array elements are unique, you could return the array element (variant), convert it and scan the original array to get the index. But as mentioned, it works only if all values of your array are unique. Quote Link to comment
BobHamburger Posted December 23, 2008 Report Share Posted December 23, 2008 One approach uses the Value Changed event. Wire the OldVal and NewVal nodes to an inequality comparison, with the Comparison Mode set to Compare Elements. Search for the first True value and you've got your index as well as the new value. Quote Link to comment
LAVA 1.0 Content Posted December 23, 2008 Report Share Posted December 23, 2008 QUOTE (Minh Pham @ Dec 21 2008, 11:39 PM) ... it does have the Mouse Co-ordinate values returned which can be used but it is not the optimal way ofdoing this i guess, you still have to figure out which item within the array is clicked/double-clicked and return the index so you can process a certain task for that item (eg. change the value, or pop-up msg). LAVA CR to the Rescue. Have a look at the Array Point to RowCol submission. Ton Quote Link to comment
Norm Kirchner Posted December 23, 2008 Report Share Posted December 23, 2008 There used to be a bit of a hack that always had promise, but had some technical issues because of it's hack status. The jist is that you generate a reference off of an element in an array, Register that for the mouse down or choice of event, have an event structure handle that event and when it fires, use the CtlRef that is presented and suck out the value from the ref or whatever other info you need (although index is not one of those). So that being said the LAVA CR might be your best bet, but I always liked this trick or the potential it possessed. See link http://screencast.com/t/rtgvYhF7Yt7 Quote Link to comment
PJM_labview Posted December 23, 2008 Report Share Posted December 23, 2008 Interesting Trick Norm! Thanks for sharing. PJM Quote Link to comment
vugie Posted December 23, 2008 Report Share Posted December 23, 2008 QUOTE (Norm Kirchner @ Dec 22 2008, 06:32 AM) The jist is that you generate a reference off of an element in an array,Register that for the mouse down or choice of event, have an event structure handle that event and when it fires, use the CtlRef that is presented and suck out the value from the ref or whatever other info you need (although index is not one of those). There is much simpler approach. Array control has "Array element" propperty, which has Value property of variant type. Reading this property inside event structure for whole array event always gives you value of clicked array element (flattened to variant). If you want to get an index you can get reference of "Array Element" and search for it in array of references created before for your control. The last is not as trivial (AFAIK), at least dynamically. Quote Link to comment
Minh Pham Posted December 23, 2008 Author Report Share Posted December 23, 2008 Thanks Norm ! and Vugie! Both approaches are working just fine! I do like the Dynamic event because of its potential Awesome, that's make my GUI much better interactive Thank you for all your inputs, Im really appreciated Quote Link to comment
vugie Posted December 23, 2008 Report Share Posted December 23, 2008 I've just figured out that in case I described when you click on index rectangle, value of array element also changes. So either hide an index rectangle or check whether user clicked there Quote Link to comment
rpursley Posted December 23, 2008 Report Share Posted December 23, 2008 QUOTE (vugie @ Dec 22 2008, 04:48 AM) I've just figured out that in case I described when you click on index rectangle, value of array element also changes. So either hide an index rectangle or check whether user clicked there You can use something like this to get the index. It can be contained in a single sub-vi. Quote Link to comment
Bobillier Posted December 24, 2008 Report Share Posted December 24, 2008 Hi Few times ago i have develop this exemple. With it you can make visual selection in 1D or 2D array and obtain the index of the selection. After it's easy to get array value from is index. Eric Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.