mouse gestures

Malte Brill revolution at derbrill.de
Fri May 29 14:32:09 EDT 2009


Thanks Terry. :)

Tom: Thanks for the kind words.

 > I wonder if adding the distance  would slow it down?

I doubt. It might depend on what you want to collect, though I don´t  
think so. The lib already polls the distance from the last recorded  
x,y position to the mouseloc. If you hook in a script local var that  
you reset on libGestMouseDown and then on libGestMouseMove x,y add to  
that var you should be good. distance is implemented into the lib  
already, so that should be pretty straightforward. It could look like  
this:


-- new local here

local lDistanceTraveled

on libGestMouseDown pButton
     if pButton <> 3 then exit libGestMouseDown
     if lSensivity is empty then put 10 into lSensivity
     set the uStartGesture of me to the mouseloc
     put item 1 of the uStartGesture of me into lOldX
     put item 2 of the uStartGesture of me into lOldY
     put empty into LGestureList
     put 0 into lDistanceTraveled
end libGestMouseDown


on libGestMouseMove x,y
     if the uStartGesture of me is empty  then exit libGestMouseMove
     local tDist,tAngle
     put distance (lOldX,lOldY,x,y) into tDist
     put findAngleX(lOldx,lOldY,x,y) into tAngle
     if tDist>lSensivity then
       add tDist to lDistanceTraveled
--[snip]

function libGestLastDistanceTraveled
   return  lDistanceTraveled
end libGestLastDistanceTraveled

Now you could call libGestLastDistanceTraveled() on libGestDone and  
would be set :)

Would love to see what you come up with. :-)

Cheers,

Malte




More information about the use-livecode mailing list