Repeats and mouse events

Scott Rossi scott at tactilemedia.com
Wed Feb 13 17:06:01 EST 2002


On Wednesday, February 13, 2002, at 01:11  PM, Ken Norris (dialup) wrote:

> The following is a script I experimented with in Hypercard which uses 
> the
> addColor XCMD to color hilite buttons, rather than the B&W button 
> Autohilite
> property. It's simple, and can be used in an offscreen handler that will
> make all the buttons which call it behave the same way, e.g., just like
> autohilite. I'd think it would belong in a group script in RR. It's the
> recoloring technique that you want to look at.
>
> on mouseUp
>   autoColorHilite
> end mouseUp
>
> on autoColorHilite
>   addColor,colorButton,bg,id of the target,"39321,26214,13107",2
>   repeat while the mouse is down
>     if the mouseLoc is within the rect of the target then
>       addColor colorButton,bg,id of the target,"39321,26214,13107",2
>     else addColor colorButton,bg,id of the target,"52428,39321,26214",2
>   end repeat
>   -- you can do all your mouseUp operations here OR use a mouseUp 
> handler
> end autoColorHilite

If you're looking to simply manage highlighting of buttons with a 
central script, the following is one way.

In your button script:

on mouseDown
   manageDownState
end mouseDown

on mouseDoubleDown # include this handler to trap fast clicks
   mouseDown
end mouseDoubleDown

on mouseUp
   manageUpState
end mouseUp

on mouseDoubleUp # include this handler to trap fast clicks
   mouseDown
end mouseDoubleUp

on mouseRelease
   mouseUp
end mouseRelease


In your stack script:

on manageDownState
   if within(the target,the mouseLoc) then \
       set the backColor of the target to 0,255,0 #<your "down" RGB color 
here
   set the uAllowButtonTracking of me to true
end manageDownState

on manageUpState
   set the backColor of the target to 128,128,128 #<your "up" RGB color 
here
   set the uAllowButtonTracking of me to false
end manageUpState

on mouseMove
   if not the uAllowButtonTracking of me then exit mouseMove
   if within(the target,the mouseLoc) then
     set the backColor of the target to 0,255,0 #<your "down" RGB color 
here
   else set the backColor of the target to 128,128,128 #<your "up" RGB 
color here
end mouseMove



Regards,

Scott Rossi
Creative Director, Tactile Media
scott at tactilemedia.com
http://www.tactilemedia.com




More information about the use-livecode mailing list