More send in time

Dar Scott dsc at swcp.com
Mon Jun 30 14:43:00 EDT 2003


On Monday, June 30, 2003, at 09:21 AM, Ken Norris wrote:

> I'm still having problems understanding 'send in time'
>
> I want to send continuous messages to scroll a field while the cursor 
> is
> within a graphic while the mouse is down. It's been reiterated a 
> number of
> times that it's not a good idea to use 'mouseWithin' or  
> 'mouseStillDown' or
> 'while the mouse..' or 'until the mouse..' in Rev.
>
> As an example, here's how I would write it in a normal HyperTalk 
> structure:
>
> on mouseDown
>   repeat until the mouse is up
>     if the mouse is within graphic 1 then
>        set the vScroll of fld 1 to (the vScroll of fld 1) - 1
>     else beep
>   end repeat
> end mouseDown
>
> How should I rewrite this to get the exact same effect with a 'send in 
> time'
> construct?

I don't think this is a send-in-time question.  It is a mouse event 
question.

The problem is that mouseEnter, mouseLeave and even mouseWithin or 
mouseMove are not sent to alternate objects when the mouse button is 
down.  If they were, then you could use those to change the action of 
the button being held down.

I can only think of a few ways:
1.  the mouseLoc is within the rectangle of graphic "Test"
2.  use some graphic other than the mouse pointer for moving over the 
graphic
3.  figure out some way to use drag

The send-in-time script for #1 is adapted straight from a cookbook 
message-machine script:

local scrollMonitorID = ""

on startScrollMonitor
   if scrollMonitorID is empty then
     send "monitorScroll" to me in 0 seconds
     put the result into scrollMonitorID
   end if
end startScrollMonitor

on stopScrollMonitor
   cancel scrollMonitorID
   put empty into scrollMonitorID
end stopScrollMonitor

on monitorScroll
   if the mouseLoc is within the rectangle of graphic "Test"  then
     set the vScroll of field "test" to (the vScroll of field "Test")-1
   else
     beep
   end if
   send "monitorScroll" to me in .4 seconds  -- put in if to have diff 
times
   put the result into scrollMonitorID
end monitorScroll

on mouseDown
   startScrollMonitor
end mouseDown

on mouseUp
   stopScrollMonitor
end mouseUp

on mouseRelease
   stopScrollMonitor
end mouseRelease

Just put that in your card script and make sure you have the field 
"Test" and the graphic "Test".

If you need to avoid mouseLoc(), then you may have to try something 
else.

Dar Scott





More information about the use-livecode mailing list