10-06-2015 06:42 AM
Hi,
I am constructing a 5x3 boolean array as an input. I add an array indicator and when I run the program, when i push a button in the array input the corresponding light goes on,on the indicator.
So now, I am trying to get the x,y coordinates of the button pushed so I can use this information in a program.
I cant seem to get the x,y coordinates out.....HELP!
Brian
10-06-2015 06:48 AM
Hi Brian,
If you use an event structure, a mouse down or mouse up event on the array control will return the coordinates.
10-06-2015 07:10 AM
Using an event structure, you can get the "old value" and the "new value". Use a Not Equal and then do a search for the TRUE.
10-15-2015 10:23 AM
Thanks, but I don't understand the mouse up/down part...
10-15-2015 10:29 AM
@Metalhead wrote:
Thanks, but I don't understand the mouse up/down part...
I recommend using the Value Change event. That event gives you the "old" and "new" value of the array. Just do a comparison and find the first element that is different.
10-15-2015 10:56 AM - edited 10-15-2015 11:22 AM
@crossrulz wrote:
I recommend using the Value Change event. That event gives you the "old" and "new" value of the array. Just do a comparison and find the first element that is different.
If course if people would actually vote for my idea here, things could get simplified. You could simply do a "array min&max" on the "not equal" array. (see the idea discussion for details).
Until then we could use this (Also works for higher dimensions, 3D, 4D, etc.!):
(Other methods for finding the true element of a 2D boolean array requires reshaping to a 1D array, for loops, or other flaming hoops)
10-15-2015 11:56 AM
I like Altenbach's answer, that's a pretty slick bit of code, but I"m trying to figure out what you are working on that needs this. Is this just an assignment in a class? What are some real life uses for this?
10-15-2015 12:12 PM
To be clear, are you talking about xy coordinates on your screen, or are you talking about xy position in your array?
10-15-2015 01:37 PM
Or the array indexes (indices) of the clicked boolean?
Lynn
10-15-2015 01:41 PM
...So now, I am trying to get the x,y coordinates of the button pushed so I can use this information in a program.
I think it is quite clear that he meant indices. i.e. the information quantized to the buttons. It is probably less intersting to know on which pixel a certain button was clicked. 😄