So I am having trouble with touch events. The following code demonstrates what is happening:
local background = display.newRect(100,100,400,400)
background:setFillColor(255,0,0)
local bar = display.newRect(100,100,200,200)
function listener(event)
print(event.phase)
if(event.phase == "begin") then
display:getCurrentStage():setFocus(event.target)
elseif(event.phase =="moved") then
elseif(event.phase == "ended" ) then
display:getCurrentStage():setFocus(nil)
end
return true
end
bar:addEventListener("touch", listener)
background:addEventListener("touch", listener)
This code prints the event from within the listener.
First touch the white square and drag off to the left onto the black background. Notice how no end event was fired?
Next touch the white square and drag off to the left onto the red square.
Notice how the end event fired this time?
The red square got my end event!
Why did the white square not get an end event when you drag off from it?
Is this intended?
[import]uid: 106158 topic_id: 26788 reply_id: 326788[/import]