Malik Posted May 28, 2008 Report Share Posted May 28, 2008 Hey, I have an 2-dimensional Array of LEDs - and what I want to do is turn all the Leds the mouse goes into ON. I couldn't find a way to have the events for the single LED being hanldes - it always handles all the array. Thanks for the help. A second question: Is there an easy way to have a control, in which the user can draw a line - and me getting the data into an array or something. Thanks again Quote Link to comment
JDave Posted May 28, 2008 Report Share Posted May 28, 2008 QUOTE (Malik @ May 27 2008, 09:59 AM) I have an 2-dimensional Array of LEDs - and what I want to do is turn all the Leds the mouse goes into ON. I couldn't find a way to have the events for the single LED being hanldes - it always handles all the array. That is the expected behavior of arrays. To see which element needs to be toggled, you need to convert the mouse coordinates to array indices. This bit of code can help with that. Do you want to toggle on Mouse Move or on a Mouse Click? QUOTE (Malik @ May 27 2008, 09:59 AM) A second question: Is there an easy way to have a control, in which the user can draw a line - and me getting the data into an array or something. Not really. You will have to capture the mouse motion yourself and translate that to the data you are interested in. Quote Link to comment
Malik Posted May 29, 2008 Author Report Share Posted May 29, 2008 I want to toggle at mouse move Quote Link to comment
Norm Kirchner Posted May 29, 2008 Report Share Posted May 29, 2008 This is one of my favorite hacks! Check out the BD below. The premise is that you register a reference to the element of the array to the dynamic event for "mouse in" and when the event is fired, it will return a reference which you can modify the value of the control. It's buggy and not perfect. Especially if the array changes size. I have found that if you do not change the size of the array and to not move the indexes of the array around you can have some good success Never mind, looks like they fixed my hack. There is no truly simple way to do what you're looking for w/ only using an event structure and not much else. The best you can do is register a reference to "Array Element" (property of array) to the dynamic event registration terminal and you will get a new event fired each time you enter an element. But you will need to do your own math to determine which element you just went into by using mouse position.. Once you do that math, you can update the value of the array. But even then you can't get the true position of the cursor when the event was fired and if the user moves the mouse fast enough, you will end up w/ bad results Your best bet is to give more details as to what your end (alternative) goal is and we may be able to come up w/a better solution. Code stub shown Quote Link to comment
Michael Aivaliotis Posted May 29, 2008 Report Share Posted May 29, 2008 If it's a fixed number of elements perhaps an array is not needed but you can use a cluster? Then it's easy. 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.