Hi,
for a widget.scrollView object there’s a way to pass a touch event to the scrollView, when a button inside the scrollView was dragged with a finger. Sth like this placed in a button’s touch handler:
if(e.phase == "moved") then local dx = abs(e.x - e.xStart) local dy = abs(e.y - e.yStart) -- if finger drags button more than 15 pixels, pass focus to scrollView if(dx \> 15 or dy \> 15) then display.getCurrentStage():setFocus( nil ) e.target = scrollView.\_view e.phase = "began" scrollView.\_view.touch( scrollView.\_view, e ) scrollView:takeFocus(e) elseif(e.phase == "ended") then
I’d like to make sth similar, but with physics objects - so when I drag button which is inside a mapGroup (display.newGroup()) object with a physic body attached - I’d like to pass a touch event from the dragged level button to a mapGroup. I’m trying with this placed in a level button’s touch handler:
if(e.phase == "moved") then local dx = abs(e.x - e.xStart) local dy = abs(e.y - e.yStart) -- if finger drags button more than 15 pixels, pass focus to mapGroup if(dx \> 15 or dy \> 15) then display.getCurrentStage():setFocus( nil ) e.target = mapGroup e.phase = "began" mapGroup.\_view.touch( mapGroup.\_view, e ) display.getCurrentStage():setFocus( e.target ) e.target.isFocus = true end elseif(e.phase == "ended") then
but the line “mapGroup._view.touch( mapGroup._view, e )” doesn’t seem to work with a non-scroll widget object.
Without that line I’m passing just focus to a mapGroup object, but there’s an error due to the lack of touch event data which was not passed.
Does anyone tried to passing a touch event to a display object and could assist me on doing that?
Thanks!