Anonymous functions are great except for when adding them as event listeners.
Internally the event listeners are tracked in a table that includes two keys: the event type, i.e. “touch”, “tap”, etc. and the address of the function being added.
If you do:
object:addEventListener(“touch”, function( event ) doSomething=true; end)
An address to the anonymous function is generated and stored in the internal table. You have no access to that address. If you later try and do:
object:removeEventListener(“touch”, function( event ) doSomething=true; end)
That’s a new anonymous function with a different memory address and we can’t find it in the table so it doesn’t get removed. Now for things like touch on an object it’s not a big deal because you can remove the object later. But for Runtime, or “enterFrame” operations, anything you have to remove yourself, it’s a problem. Your ScrollView anonymous function is okay because you won’t ever need to remove it.
ScrollViews have a method called takeFocus (https://docs.coronalabs.com/api/type/ScrollViewWidget/takeFocus.html) that can be used to have the ScrollView take the focus if you detect movement in an object inside the scrollView. I know this works when you have scrollViews inside of other scrollViews (say one is horizontal only scrolling and the other is vertical only). You might be able to use this to help.
Still I would avoid putting a touch listener on the Runtime.
Rob