Multi-Touch Swipe V or H Direction

Getting into LiveCode for iOS? Ask your questions here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
quailcreek
Posts: 688
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Multi-Touch Swipe V or H Direction

Post by quailcreek » Sun Mar 25, 2018 11:42 pm

Hi,
Has anybody worked out how to detect a 2 finger vertical and horizontal swipe? I looked at Ben's Touch Detection stack in the sample stack area but but I'm not getting what I need. Thanks in advance for the help.
Tom
MacBook Pro OS High Sierra 10.13.3

MaxV
Posts: 1481
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Multi-Touch Swipe V or H Direction

Post by MaxV » Tue Mar 27, 2018 12:50 pm

Try this:
########CODE to copy and paste with your mouse#######
global gPosition
global gTouch

on openCard
put empty into gPosition
end openCard

on mouseDown
put item 1 of the mouseLoc into gPosition
end mouseDown

on mouseUp
put empty into gPosition
end mouseUp

on mouseMove pX
if gPosition is not empty and 200 < (gPosition - pX) then
put empty into gPosition
visual effect push left
go to next card #this is a typical action with swipe
if gTouch = 2 then
answer "swiped with 2 fingers!"
end if
end if
end mouseMove

on touchStart pTouchId
# Sent each time a new touch is started
add 1 to gTouch
end touchStart

on touchEnd pTouchId
# Sent each time a touch ends
add -1 to gTouch
end touchEnd
########END OF CODE generated by this livecode app: http://tinyurl.com/j8xf3xq ########
########Code tested with livecode 9.0.0-rc-1########
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

quailcreek
Posts: 688
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: Multi-Touch Swipe V or H Direction

Post by quailcreek » Wed Mar 28, 2018 2:45 am

Thanks, MaxV,
I didn't realize I could use mouseLoc with a 2 finger touch.
Here's what I ended up with for a vertical swipe.

Code: Select all

local sPosition,sTouchCount,sTouchV

on openCard
  put empty into sPosition
  put empty into sTouchCount
  put empty into sTouchV
  put "2 finger virtical swipe" into fld "log"
end openCard

on mouseDown
  put item 2 of the mouseLoc into sPosition
end mouseDown

on mouseUp
  --  put "sPosition" && sPosition &CR& "sTouchV" && sTouchV &CR& (sTouchV - sPosition) into fld "log"
  
  if sPosition is not empty and (sTouchV - sPosition) > 40 then
    
    if sTouchCount = 2 then
      put empty into sPosition
      visual effect "push" down
      go card "setup"
    end if
  end if
  put empty into sPosition
end mouseUp

on mouseMove pTouchH, pTouchV
  if environment() is not "mobile" then exit to top
  
  put pTouchV into sTouchV
end mouseMove

on touchStart pTouchId
  add 1 to sTouchCount
end touchStart

on touchEnd pTouchId
  subtract 1 from sTouchCount
end touchEnd
Tom
MacBook Pro OS High Sierra 10.13.3

Post Reply

Return to “iOS Deployment”