How do you deliberately permit touch propagation only during the begin and moved phases?

There’s a grid of square buttons representing levels on top of a scroll. If a user begins the touch on the scroll , moves across 100 pixels in dx and releases the finger at the scroll, then the scroll moves in the direction of the slide. However, if the player starts the touch with the square button widget, but performs the same motion as earlier, the scroll touch handler doesn’t activate. But, I’d like to such that the user can scroll across the grid seamlessly without to scroll outside of it while the only time the button gets activated is when the player begins and ends the touch on it.

Any ideas on how I could achieve this? :slight_smile:

You will need to detect the x-movement to see whether the user is sliding left / right.

After that, just give the scroll view the focus using “scrollView:takeFocus()”

You can look at this code below to give you an idea. I have not tested it, but it should work.

local object = display.newImage( "ball.png" ) local startX local startY function object:touch( event ) if event.phase == "began" then startX = event.x startY = event.y elseif self.isFocus then if event.phase == "moved" then -- Check where the user is moving. if (event.x - startX) \< 0 then -- Sliding left ? end if (event.x - startX) \> 0 then -- Sliding right ? -- Give focus to the scroll view scrollView:takeFocus() return true end elseif event.phase == "ended" or event.phase == "cancelled" then end end return true end object:addEventListener( "touch", object )

You will need to detect the x-movement to see whether the user is sliding left / right.

After that, just give the scroll view the focus using “scrollView:takeFocus()”

You can look at this code below to give you an idea. I have not tested it, but it should work.

local object = display.newImage( "ball.png" ) local startX local startY function object:touch( event ) if event.phase == "began" then startX = event.x startY = event.y elseif self.isFocus then if event.phase == "moved" then -- Check where the user is moving. if (event.x - startX) \< 0 then -- Sliding left ? end if (event.x - startX) \> 0 then -- Sliding right ? -- Give focus to the scroll view scrollView:takeFocus() return true end elseif event.phase == "ended" or event.phase == "cancelled" then end end return true end object:addEventListener( "touch", object )