Hyper-tap event

It took me a few days to understand what was going on… :rofl:

In my project I use ScrollView filled-in with paragraphs and titles of text returned as database search results.
Both the title & paragraph have an invisible rect-object as a transparent background with a listener which redirects to another scene when clicked (I mean “tap”, not “touch”).
If I initiate another database search, I delete everything from the ScrollView and fill it in with new search results.
I also have a couple of buttons which show previous 20 and next 20 results, they work exactly in the same manner: the previous results are removed and new are drawn and added…

Now look what I found when I click a button to show previous results: the ScrollView is updated SO QUICKLY that a touch of button works as a tap-event on an object which was created a millisecond ago! I call it hyper-tap.

Any ideas how to avoid it? (To my mind there must be a proper function to virtually abort a touch/tap/move event as I described here… Still not answered thought.

Added later: going to a transitional scene and then going back helps, but I do not want to reload the scene, I would prefer to update the ScrollView… still

  1. I suggest using ‘touch’ for everything, but especially GUIs.
    Honestly, I wish tap did not exist. It causes problems like this for new users all the time.

My guess is the tap event is immediately drawing the new content and buttons with tap events and your finger motion as you go to lift is is registered as a new tap on the new objects in the next frame.

  1. Don’t take immediate action. Just execute in the next frame.
local function obj.touch( self, event )
   if ( event.phase == "ended" ) then
      timer.peformWithDelay( 1, function() ...the action here... end )
   end
   return false
end

1 Like

No need to play with Delays now. I set up “touch” instead of “tap”, added a few lines to remove focus off the ScrollView, No problems so far… Thank you for the advice.