Continuous MouseDown Colorization of Graphic Grid?

Devin Asay devin_asay at byu.edu
Mon Jan 25 16:32:24 EST 2010


Hi John,

On Jan 25, 2010, at 2:15 PM, John Patten wrote:

> Hi All...
>
> I've created a grid of graphic rectangles that I can colorize and make
> transparent (blend). I would like to be able to let the user drag the
> mouse while holding the mouse button down and colorize each rectangle
> they drag across.  On the flip side, if the rectangle is already
> colorized, I would like to it to turn it's blend level to 100 and set
> its color to empty. Again, if there were a series of rectangles in the
> grid that were colorized, dragging across them with the mouse down
> with de-colorize them.
>
> I can't seem to get my head around the mousedown while dragging part?
> I've tried mouseEnter, but that gets messy when accidentally dragging
> over a rect in the grid you don't want colorized; I have tried
> MouseStillDown with no luck there either.
>
> Anyone done anything similar with a transparent grid?
>
> The grid would sit on top of an image, like for example a map, and the
> colorizing would enable the user to, essentially, focus in on a
> particular part of the image below.

The problem with most mouseMessages is that they are only sent to the  
object where the action originates. What is more, most mouse messages,  
like mouseEnter and mouseLeave, are not sent while the mouse is held  
down. The exception is mouseMove, which gets sent all the time, even  
when the mouse button is down. When I have had to do similar things to  
what you're doing, I have used a mouseMove handler and checked to see  
if the mouse is within various objects. If there aren't too many  
objects you're checking a switch statement seems to work well.  
Something like:

on mouseMove
   put the mouseLoc into tLoc
   switch
     case tLoc is within btn "a"
       -- do stuff to btn "a"
     break
     case tLoc is within btn "b"
       -- do stuff to btn "b"
     break
     -- etc., etc.
   end switch
end mouseMove

HTH

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list