Drop list GUI problem

Started by
10 comments, last by aregee 12 years, 7 months ago

It seems you are scanning each row and column of your image to test if the mouse button was clicked there. A better way of finding out whether your mouse pointer was clicked inside the image or not is to test against the borders of your image.


you are correct, i'm scanning for every pixel of the image to see if that pixel was clicked or not. why do you think scanning every pixel is not a good idea ? do you think the software will get slower and the CPU will have more calculations to do ?

and thank you for the code its work perfectly :D
Advertisement

[quote name='aregee' timestamp='1315018970' post='4857019']
It seems you are scanning each row and column of your image to test if the mouse button was clicked there. A better way of finding out whether your mouse pointer was clicked inside the image or not is to test against the borders of your image.


you are correct, i'm scanning for every pixel of the image to see if that pixel was clicked or not. why do you think scanning every pixel is not a good idea ? do you think the software will get slower and the CPU will have more calculations to do ?

and thank you for the code its work perfectly :D
[/quote]

Scanning each pixel in the image is bad because it is slow. Maybe not that slow on a small image, but what if your button was like 100x100 in size, or even bigger, or if you have many such small images to check for a button down event. It would take "ages". (Even a couple of hundred millisecond feels like ages in a user interface.) What I did takes the same amount of time regardless of the size of the image.

I am glad my example worked. It was made to give you some ideas of alternative ways to do things. It is not by way the only or best solution at all. I would actually have a look at what Serapth posted just after me. It seems to be a much more elegant solution than mine. :)

This topic is closed to new replies.

Advertisement