Event propagation issue when using gameUI.lua

Hi!

I’m using the dragBody function in gameUI.lua to drag objects around a screen. The objective of the interaction is to find the hidden object. The problem is, when you tap on objects that are over the hidden object, the hidden object registers the touch (without it actually being found). 

Has anyone got any way around this?

In my code I can calling the function like so:

 local function dragBody( event ) return gameUI.dragBody( event )  end 

I haven’t altered any code in gameUI.lua. The above function is attached to numerous objects. 

GameUI.lua already returns true so I thought this would solve the problem.

Any ideas?

Thanks :slight_smile:

The gameUI library isn’t something created by Corona Labs. Do you know who created it? If so you might want to ask them. If it’s something you got from the community code, perhaps you can post the URL to it so people can go look at the code.

The symptoms here are that the touch handler in .dragBody() isn’t returning true after processing it’s touch event.

Rob

I got the gameUI library from the MultiPuck project in the Corona sample projects folder… 

Interesting… who knew? Any way, it’s returning true like t should. But it’s only going to handle touch actions. If your object has a tap handler on it, it’s going to propagate through. Tap and Touch are different events.

Your code above doesn’t show how you’re creating the touch object, so we might need to see some more code.

Rob

I’m applying touch handlers to objects that are to be dragged:

gloves:addEventListener("touch", dragBody)

For the object that the user is searching for I have applied a tap handler (it is a static object, tapping it just loads the next scene):

  flashlight:addEventListener("tap", foundTorch)

As I said above, touch and tap are different events. If you don’t want taps on your drag-able objects to make it to things underneath, you also have to add a tap handler to your globes object:

local function ignoreTap()     return true end gloves:addEventListener( "tap", ignoreTap )

or something like that.

Rob

The gameUI library isn’t something created by Corona Labs. Do you know who created it? If so you might want to ask them. If it’s something you got from the community code, perhaps you can post the URL to it so people can go look at the code.

The symptoms here are that the touch handler in .dragBody() isn’t returning true after processing it’s touch event.

Rob

I got the gameUI library from the MultiPuck project in the Corona sample projects folder… 

Interesting… who knew? Any way, it’s returning true like t should. But it’s only going to handle touch actions. If your object has a tap handler on it, it’s going to propagate through. Tap and Touch are different events.

Your code above doesn’t show how you’re creating the touch object, so we might need to see some more code.

Rob

I’m applying touch handlers to objects that are to be dragged:

gloves:addEventListener("touch", dragBody)

For the object that the user is searching for I have applied a tap handler (it is a static object, tapping it just loads the next scene):

  flashlight:addEventListener("tap", foundTorch)

As I said above, touch and tap are different events. If you don’t want taps on your drag-able objects to make it to things underneath, you also have to add a tap handler to your globes object:

local function ignoreTap()     return true end gloves:addEventListener( "tap", ignoreTap )

or something like that.

Rob