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.
Multi-Touch Swipe V or H Direction
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
- Location: McKenna, WA
Multi-Touch Swipe V or H Direction
Tom
MacBook Pro OS Mojave 10.14
MacBook Pro OS Mojave 10.14
Re: Multi-Touch Swipe V or H Direction
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########
########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: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
- Location: McKenna, WA
Re: Multi-Touch Swipe V or H Direction
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.
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 Mojave 10.14
MacBook Pro OS Mojave 10.14