Touch event.phase "ended" does not trigger on whole screen / Runtime

Hi,

I spent last few hours trying to find a solution to the problem of detecting “ended” phase on touch event for the whole screen. This is the code I use at the moment:

screenTouching = false function screenTouch( event )     if event.phase == "began" then -- event started         display.getCurrentStage():setFocus( event.target )         screenTouching = true     elseif event.phase == "moved" then         -- event/touch still in progress             else         -- DOES NOT TRIGGER -- event/touch ended         display.getCurrentStage():setFocus( nil )         screenTouching = false     end     return true end Runtime:addEventListener("touch", screenTouch)

I need a global variable that is saying if screen is being touched at any moment.

This code above, nor the default examples, are not working with “Runtime” being the object.

Thank you! :slight_smile:

@Exevio,

I think the problem is this line: display.getCurrentStage():setFocus( event.target )

You’re using a ‘Runtime’ listener, so there is no object to set as the focus.  

Try removing it and see what you get.

Also, Are you sure you don’t have any other listeners going at the same time.  i.e. This is the only active touch listener?

-Ed

@Exevio,

I think the problem is this line: display.getCurrentStage():setFocus( event.target )

You’re using a ‘Runtime’ listener, so there is no object to set as the focus.  

Try removing it and see what you get.

Also, Are you sure you don’t have any other listeners going at the same time.  i.e. This is the only active touch listener?

-Ed