Jump to content

Mouse Event Handling in Array of Leds


Recommended Posts

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

Link to comment

QUOTE (Malik @ May 27 2008, 09:59 AM)

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.

Link to comment

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

4ce0d9e8-7786-4d8c-87c1-ae1326acef81_339e165d-366f-4cc2-81aa-1e06c36c823d_static_0_0_2008-05-28_0850.png

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.