I worked on this a bit more and you are right, without the returns things go awry.
I ended up doing it like this which works well if you don’t have scrollviews etc. All non dragging touches go through.
[lua]local startX
local touchPanelActive
local function touch(e)
if not composer.backSwipeActive then
return false
end
local phase = e.phase
if not touchPanelActive then
if phase == “began” then
startX = e.x
elseif phase == “moved” and e.x - startX > 5 then
print(“Touchpanel activated”)
composer.getCurrentScene():dispatchEvent{ name=“swipe”, phase=“activated” }
touchPanelActive = true
touch({x = e.x, y = e.y, target = e.target, phase = “began”}) – Call function again with began phase but with activated touchpanel
end
else
– Previous touch function unchanged except touchPanelActive = false on cancel and complete
[/lua]
One thing I would want to do is not to load the back scene that is underneath until old scene has been completely swept away. Right now it loads it as soon as you let go and in my case the scene underneath has to access db which means stuttering during the transition.
So I’m doing it like this at the moment:
[lua]-- Before dispatching ended phase, move view out of the way
transition.to( view, { time=50, x=display.contentWidth, onComplete=function()
composer.getCurrentScene():dispatchEvent{ name=“swipe”, phase=“ended” }
end } )[/lua]
It looks a tiny bit odd, but its so fast that its hardly noticeable. There is probably a better way.