[Resolved] Prevent event from being listened

Hello everyone

If I have two objects that are overlapping each other, each with it’s own touch eventlistener, is there any way I can prevent the event from the second object of happening after the first one was triggered?

I tried using a simple boolean, but as my first object is a button from UI library, it won’t trigger any events upon releasing the mouse outside of its bounds.

Maybe there’s a function that stops an event propagation…

Thanks!!!

[import]uid: 151732 topic_id: 27386 reply_id: 327386[/import]

Hey there,

Yes, absolutely - return true!

[lua]–Button 1
local btn1 = display.newCircle( 150, 100, 30 )
btn1:setFillColor(255, 0, 0)

–Button 2
local btn2 = display.newCircle( 170, 100, 30 )

–Tap function
local function tapBtn(event)
print “event fired!”
return true
end
btn1:addEventListener(“tap”, tapBtn)
btn2:addEventListener(“tap”, tapBtn)[/lua]

That will show you how it works :slight_smile:

Peach [import]uid: 52491 topic_id: 27386 reply_id: 111278[/import]

Thanks a lot, Peach.
Are you the only one who can see what I post? you are the only one that ever answered me here :slight_smile:

BTW, I actually tried to return false once, hehehe

[import]uid: 151732 topic_id: 27386 reply_id: 111434[/import]

No worries :slight_smile:

As to your posts, haha, no, everyone can see them but I spend a lot more time here than most people so I tend to answer first.

I think early on I tried to do that too, return false - though I did a lot of odd things with my code back then :wink: [import]uid: 52491 topic_id: 27386 reply_id: 111472[/import]