I am noting that using setFocus is causing multitouch events to stop being received. Is this a bug?
If not any ideas on how to work around what I am seeing. Sample code is below. To reproduce:
* Touch the rectangle with finger A (keep down)
* Touch rectangle somewhere else with finger two, and note there is no event with a separate unique id (well no event at all in fact)
My goal/requirements are:
* To have an area (the rectangle) accept multiple touch events, including moves
* Ensure that when any finger slides out of rectangle, or quickly right off screen, that the touch listener code ensures that an “ended” event is detected
* So if you like the touch listener is to be a model that passes on multitouch events ON/MOVED/OFF to another module robustly such that there should never be a single multitouch event for which an “OFF” is missed being passed (i.e. each ON for a specific multitouch unique needs to have a corresponding OFF with the same multitouch unique id)
Code
system.activate( "multitouch" ) local displayW, displayH = display.contentWidth, display.contentHeight local myRectangle = display.newRect( displayW/2, displayH/2, displayW/2, displayH/2 ) myRectangle.strokeWidth = 3 myRectangle:setFillColor( 0.9, 0.9, 0.9 ) myRectangle:setStrokeColor( 1, 1, 0 ) local function touchListener(event) local uniqueTouchId = event.id if event.phase == "began" then display.getCurrentStage():setFocus(event.target, uniqueTouchId); -- SET FOCUS event.target.isFocus = true; print("BEGAN:", uniqueTouchId, event.phase) elseif event.phase == "moved" and event.target.isFocus then elseif event.target.isFocus then -- for ended or cancel display.getCurrentStage():setFocus(event.target, nil); -- REMOVE FOCUS event.target.isFocus = nil; print("ENDED:", uniqueTouchId, event.phase) end end myRectangle:addEventListener("touch", touchListener)