Constraining the pointer within a rect

Phil Jimmieson P.Jimmieson at csc.liv.ac.uk
Thu Aug 17 09:02:16 EDT 2006


>Greetings
>
>This is my annual mailing on this topic.  I won't bore you with why 
>I need to do this deprecated act, but I do.
>
>Basically I need the pointer to refuse to move outside a rect, and 
>just 'bounce' against the edge.  No recoil or anything fancy, just 
>stop until the user moves elsewhere with the rect.  I had a script 
>that worked in a standalone in 1.1.1.  It was inelegant, but 
>effectively.  It became painfully slow and jerky in 2.x.
>

Hi David,
basically, this modified version of the script works:

on mouseMove X,Y
   if the hilite of button "constrain" is true then
     put the rect of fld "container" into  Fred
     put min (item 3 of Fred , max (item 1 of Fred, X)) into X
     put min (item 4 of Fred , max (item 2 of Fred, Y)) into Y
    
     get the globalloc of (X,Y)
     set the screenMouseLoc to it
   end if
end mouseMove


but it is *incredibly* slow on OSX (not tried on Windows). I'm not 
quite sure what it is that's slowing this down - does setting the 
ScreenMouseLoc send a MouseMove message itself? There's bound to be a 
better way of doing this?
-- 
Phil Jimmieson  phil at csc.liv.ac.uk  (UK) 0151 795 4236  (Mobile) 07976 983164
Computer Science Dept., Liverpool University, Ashton Building, Ashton Street
Liverpool L69 7ZF              http://www.csc.liv.ac.uk/~phil/
   I used to sit on a special medical board... ...but now I use this ointment.


More information about the use-livecode mailing list