Touch Propagation issue after SDK update

Hello,

 I’ve been using Corona for about two years now and only recently updated the sdk software version. My original version was from May 2014 timeframe (I think). I downloaded “2016.2992 (2016.11.10)” version and now my touch propagations do not work correctly. Any touch listener with a “return true” before the update worked correctly and after the update, they do not. I would post the code but it is quite complex (probably unnecessarily). I am looking for any possible issues with the updates that might come to mind. Any suggestions?

First of all, it’s amazing that you didn’t have to update for two years. How did that happen?

Can you strip down the touch code to its basics so we can see what’s going on?

Yeah - we really need to see this not working as expected so we can help.

Hi Guys,

   Thank you for the prompt responses. I apologize for not posting my code (I’m aware that can be frustrating when you are offering your time to help). My code is very complex with many scripts that handle display groups involved with these touch events (likely too complex and the true source of my problem). I suspect my issue is either 1) associated with the order of one of my display groups changing incorrectly, or 2) associated with something I’m doing incorrectly in my touch listener function. First, I did verify just now that the issue is not the sdk version as the following simple test code runs correctly when touching in the overlapping and non-overlapping regions (when both retaining and commenting out “return true” in the touch listener functions):

local gs = {}  -- table for groups local all\_func = {}  -- table for functions                            all\_func.testtouchfun = {} all\_func.testtouchfun2 = {} gs.touchsensetest = display.newGroup( )  gs.touchsensetest2 = display.newGroup( )  -----------------------------------------  ----------------------------------------- gs.touchsensetest.detector = display.newRect( gs.touchsensetest, display.contentWidth/2, display.contentHeight\*.5, 300, 400 );  gs.touchsensetest2.detector = display.newRect( gs.touchsensetest2, display.contentWidth/3, display.contentHeight\*.4, 400, 400 );  gs.touchsensetest2.detector:setFillColor( 1,0,0 ) gs.touchsensetest2:toBack() ----------------------------------------- functions ----------------------------------------- function all\_func.testtouchfun( e )   print("called test touch0000000000000000000000000000")   return true end function all\_func.testtouchfun2( e )   print("called test touch2------------------------------")   return true end ----------------------------------------- listners ----------------------------------------- gs.touchsensetest.detector:addEventListener( "touch", all\_func.testtouchfun )  gs.touchsensetest2.detector:addEventListener( "touch", all\_func.testtouchfun2 )  

So, not surprisingly, it is not associated with the sdk version (not sure why I experienced the issue after my update though). I do have a question about something I’m doing in my touch listener functions. Below is abridged code from my game:

-- --------------------------------------------   touch and drag-- -------------------------------------------- function all\_func.touchScreen( e )   print("called test touch0000000000000000000000000000")   colony\_guicreate\_module.touchScreen(e.target, gs.main\_group, "more display groups an d variables" )   return true end -- --------------------------------------------   tap\_upgrade -- -------------------------------------------- function all\_func.tap\_upgrade( e )   print("called tap\_upgrade------------")   if (some conditions) then     -- some code     colony\_B\_funs\_module.display\_upgrade(gs.main\_group, "more display groups and varia bles")     return true   else     -- some code     --return true   end end -- --------------------------------------------  More code -- -------------------------------------------- -- Within "scene:create" gs.touchsense.detector:addEventListener( "touch", all\_func.touchScreen ) gs.upgrade\_group:addEventListener( "tap", all\_func.tap\_upgrade )

I create an EventListener for a hittable but alpha=0 rectangle display object (for example, gs.touchsense.detector - see 2nd to last line). The listener function for this (all_func.touchScreen) then calls a function (colony_guicreate_module.touchScreen (3rd line)) from a separate script. I “return true” after calling the script within the listener and also return true at the end of colony_guicreate_module.touchScreen in the script. Is this an issue? Will either “return true” terminate the touch propagation? Thank you for the help.

Hi Guys,

It seems some of my issue is related to overlapping display objects with some having touch listeners and others having tap listeners. I have a general touch listener (attached to a display object) to look for user touch and drag activity to pan the game view. I then have several display objects with tap listeners that when tapped, display menus. If the user touches and moves, the touch listener will intentionally move the menus off-screen.

My problem since updating my mac’s iOS to (10.12.1) and the sdk to the version specified above (finally trying to get the game on a phone after two years) is that when you try to tap the objects to display the menus, the touch listener is also called and moves the menu off-screen most of the time. This is particularly true using a mouse in the Corona simulator but using my mac touch-pad greatly mitigates the issue (but does not completely solve it). I did not have this issue before the two updates (I did not test in Corona after the iOS update and before the Corona update).

Does handling a tap with “return true” prevent propagation to the touch event if they occur simultaneously (seems to occur sometimes)? If so, did this change over the last two years with updates to the sdk? When I test very old versions of the my code now I see this problem; however I am certain this was not an issue previously. 

Thank you for your time.

@TLC,

I would imagine returning true from a touch or tap listener would stop propagation of the touch event for either category.

i.e. You’re telling the system ‘this touch’ has been handled, stop processing it.

You can easily test this though, and I would definitely take the time if you are going to continue to use tap listeners.

Note: I suggest using touch  listeners exclusively.

First of all, it’s amazing that you didn’t have to update for two years. How did that happen?

Can you strip down the touch code to its basics so we can see what’s going on?

Yeah - we really need to see this not working as expected so we can help.

Hi Guys,

   Thank you for the prompt responses. I apologize for not posting my code (I’m aware that can be frustrating when you are offering your time to help). My code is very complex with many scripts that handle display groups involved with these touch events (likely too complex and the true source of my problem). I suspect my issue is either 1) associated with the order of one of my display groups changing incorrectly, or 2) associated with something I’m doing incorrectly in my touch listener function. First, I did verify just now that the issue is not the sdk version as the following simple test code runs correctly when touching in the overlapping and non-overlapping regions (when both retaining and commenting out “return true” in the touch listener functions):

local gs = {}  -- table for groups local all\_func = {}  -- table for functions                            all\_func.testtouchfun = {} all\_func.testtouchfun2 = {} gs.touchsensetest = display.newGroup( )  gs.touchsensetest2 = display.newGroup( )  -----------------------------------------  ----------------------------------------- gs.touchsensetest.detector = display.newRect( gs.touchsensetest, display.contentWidth/2, display.contentHeight\*.5, 300, 400 );  gs.touchsensetest2.detector = display.newRect( gs.touchsensetest2, display.contentWidth/3, display.contentHeight\*.4, 400, 400 );  gs.touchsensetest2.detector:setFillColor( 1,0,0 ) gs.touchsensetest2:toBack() ----------------------------------------- functions ----------------------------------------- function all\_func.testtouchfun( e )   print("called test touch0000000000000000000000000000")   return true end function all\_func.testtouchfun2( e )   print("called test touch2------------------------------")   return true end ----------------------------------------- listners ----------------------------------------- gs.touchsensetest.detector:addEventListener( "touch", all\_func.testtouchfun )  gs.touchsensetest2.detector:addEventListener( "touch", all\_func.testtouchfun2 )  

So, not surprisingly, it is not associated with the sdk version (not sure why I experienced the issue after my update though). I do have a question about something I’m doing in my touch listener functions. Below is abridged code from my game:

-- --------------------------------------------   touch and drag-- -------------------------------------------- function all\_func.touchScreen( e )   print("called test touch0000000000000000000000000000")   colony\_guicreate\_module.touchScreen(e.target, gs.main\_group, "more display groups an d variables" )   return true end -- --------------------------------------------   tap\_upgrade -- -------------------------------------------- function all\_func.tap\_upgrade( e )   print("called tap\_upgrade------------")   if (some conditions) then     -- some code     colony\_B\_funs\_module.display\_upgrade(gs.main\_group, "more display groups and varia bles")     return true   else     -- some code     --return true   end end -- --------------------------------------------  More code -- -------------------------------------------- -- Within "scene:create" gs.touchsense.detector:addEventListener( "touch", all\_func.touchScreen ) gs.upgrade\_group:addEventListener( "tap", all\_func.tap\_upgrade )

I create an EventListener for a hittable but alpha=0 rectangle display object (for example, gs.touchsense.detector - see 2nd to last line). The listener function for this (all_func.touchScreen) then calls a function (colony_guicreate_module.touchScreen (3rd line)) from a separate script. I “return true” after calling the script within the listener and also return true at the end of colony_guicreate_module.touchScreen in the script. Is this an issue? Will either “return true” terminate the touch propagation? Thank you for the help.

Hi Guys,

It seems some of my issue is related to overlapping display objects with some having touch listeners and others having tap listeners. I have a general touch listener (attached to a display object) to look for user touch and drag activity to pan the game view. I then have several display objects with tap listeners that when tapped, display menus. If the user touches and moves, the touch listener will intentionally move the menus off-screen.

My problem since updating my mac’s iOS to (10.12.1) and the sdk to the version specified above (finally trying to get the game on a phone after two years) is that when you try to tap the objects to display the menus, the touch listener is also called and moves the menu off-screen most of the time. This is particularly true using a mouse in the Corona simulator but using my mac touch-pad greatly mitigates the issue (but does not completely solve it). I did not have this issue before the two updates (I did not test in Corona after the iOS update and before the Corona update).

Does handling a tap with “return true” prevent propagation to the touch event if they occur simultaneously (seems to occur sometimes)? If so, did this change over the last two years with updates to the sdk? When I test very old versions of the my code now I see this problem; however I am certain this was not an issue previously. 

Thank you for your time.

@TLC,

I would imagine returning true from a touch or tap listener would stop propagation of the touch event for either category.

i.e. You’re telling the system ‘this touch’ has been handled, stop processing it.

You can easily test this though, and I would definitely take the time if you are going to continue to use tap listeners.

Note: I suggest using touch  listeners exclusively.