Problem with swiping in a native scroller
Posted: Sun Nov 08, 2015 1:55 pm
Hi,
I have a scrolling 'table' which uses a group of rows to display a list of ingredients in a pantry. I'm using the native scroller (under IOS) to allow the user to scroll the list vertically, but I want to implement a horizontal swipe which will move the swiped row left to reveal a delete button where necessary (same behaviour as everyday IOS apps).
I used the code below within each row 'group' to detect mouseDown and mouseUp events, capturing the amount of horizontal movement in pixels so I can then decide if the user performed a swipe or a tap/click.
The problem is, as soon as I run the app in the sim or on device it doesn't seem to be firing the mouseUp event. A click/tap works fine, but if I click/tap. hold and drag then release, the release isn't being detected.
Any ideas where I might be going wrong? The native scroller uses the onScrollerDidScroll event - is that blocking something in some way?
Regards
Chris
Code in each 'row' group
I have a scrolling 'table' which uses a group of rows to display a list of ingredients in a pantry. I'm using the native scroller (under IOS) to allow the user to scroll the list vertically, but I want to implement a horizontal swipe which will move the swiped row left to reveal a delete button where necessary (same behaviour as everyday IOS apps).
I used the code below within each row 'group' to detect mouseDown and mouseUp events, capturing the amount of horizontal movement in pixels so I can then decide if the user performed a swipe or a tap/click.
The problem is, as soon as I run the app in the sim or on device it doesn't seem to be firing the mouseUp event. A click/tap works fine, but if I click/tap. hold and drag then release, the release isn't being detected.
Any ideas where I might be going wrong? The native scroller uses the onScrollerDidScroll event - is that blocking something in some way?
Regards
Chris
Code in each 'row' group
Code: Select all
local sStartH
on mouseDown
put the mouseH into sStartH
end mouseDown
on mouseUp
put the mouseH into tMousePosn
if abs( tMousePosn - sStartH ) > 50 then
put "Detected a swipe motion"
if ( tMousePosn > sStartH ) then
if (the left of me < -1 ) then
move me relative 120,0
end if
else
if (the left of me = -1 ) then
if ( tMousePosn < sStartH) then
move me relative -120,0
end if
end if
end if
else
put "Event is a CLICK - moving to EDIT card"
set the cItemID of this stack to the short owner of the target
visual effect push left fast
go to card "editPantry"
end if
end mouseUp