Page 1 of 1

cancel mouseUp?

Posted: Sat Mar 09, 2013 12:43 am
by Nakia
Hi,

I am setting up some "swipe" actions in one of my Apps and I am wondering how can I "Cancel" the mouseUp message if I have determined a "swipe" has occurred.
Note- The below code is working but I am not canceling the mouseUp message which makes me nervous (although the mouseUp handler doesn't run if the swipe condition is met.....)


Code: Select all

on touchStart
   put the tmMenuHistory of me into lFigure
end touchStart

on touchMove pId, pX, pY
   if pId <> sTouchId then
      -- record initial values for start of swipe
      put pId into sTouchId
      put the millisecs into sInitTime
      put pX into sInitX
   end if
   -- check the action was fast enough for a swipe
   if the millisecs - sInitTime <= sSwipeTime then
      # check we have covered enough distance
      put pX - sInitX into tDistanceX
      if abs(tDistanceX) > sSwipeDistance then
        send "insertBreakPoint lFigure" to me in 0 millisecs
        end if
   end if
end touchMove

on mouseUp
   answer "No Swipe, just a Tap"
end mouseUp

Re: cancel mouseUp?

Posted: Sat Mar 09, 2013 11:36 am
by Klaus
Hi Nakia,

use a local variable:

Code: Select all

local do_mouseup
on touchStart
   put the tmMenuHistory of me into lFigure
   put TRUE into do_mouseup
end touchStart

on touchMove pId, pX, pY
   if pId <> sTouchId then
      -- record initial values for start of swipe
      put pId into sTouchId
      put the millisecs into sInitTime
      put pX into sInitX
   end if
   -- check the action was fast enough for a swipe
   if the millisecs - sInitTime <= sSwipeTime then
      # check we have covered enough distance
      put pX - sInitX into tDistanceX
      if abs(tDistanceX) > sSwipeDistance then

       ## I have no idea of mobile stuff 8-) , but I think this is wehre your SWIPE will happen:
      ## IF NOT, well you get the picture :-)
        put FALSE into do_mouseup
        send "insertBreakPoint lFigure" to me in 0 millisecs
        end if
   end if
end touchMove

on mouseUp
    if do_mouseup = FALSE then
     exit mouseup
   end if
   answer "No Swipe, just a Tap"
end mouseUp
Best

Klaus