how to disable the buttons behind current button?

hello.

My question is if some buttons behind the current button that you will touch. after touch, the buttons behind the button ( you touched button) also will active (means call functions).

So how to disable the behind buttons?

Thanks [import]uid: 38309 topic_id: 26004 reply_id: 326004[/import]

corona doesn’t automatically block buttons that are under other buttons, you’ll need to remove event listener for those buttons temporary and restore them when the whatever was above them gets closed.

to remove events:

http://developer.anscamobile.com/reference/index/objectremoveeventlistener [import]uid: 13099 topic_id: 26004 reply_id: 105271[/import]

If you just put “return true” in the listener that will only activate the top-most button

local function blah() --code return true end [import]uid: 31262 topic_id: 26004 reply_id: 105282[/import]

hi aaaron, could you be more claer. I create buttons by reading an image and assigning it to a variable and then addeventlistener on that. Perhaps you create buttons using ui lib? [import]uid: 13099 topic_id: 26004 reply_id: 105298[/import]

Hi Nermion,

It doesn’t matter how you create the buttons. You just have to put the “return true” in the listener. Danny explains it more eloquently in this thread:

http://developer.anscamobile.com/forum/2012/03/19/preventing-multiple-clicks-buttons [import]uid: 31262 topic_id: 26004 reply_id: 105305[/import]

I think you missunderstood our problem :slight_smile:

we want to prevent clicking on anything clickable that is under current button that we want to click, link you provided and “return true” suggestion seem to be a solution for problem where user desires to “prevent multiple clicks on a button” and not really a solution where user wants to block a tap propagating through all the buttons that happen to be positioned over eachother.

Correct me if I’m wrong, I dont see how the solution that was provided in the link will stop all other buttons evenlisteners picking up the tap event which is what we wanted to know, so my suggestion you have to disable everything clickable button under top button seems to be only way.

If I’m wrong can you show me example with 2 buttons positioned one over another where only top button will pick up the event and not the bottom button? [import]uid: 13099 topic_id: 26004 reply_id: 105316[/import]

hmm well my bad :slight_smile:

this comment:

afaik, returns true means that the touch event won’t get propagated further.

well, that settles the question :slight_smile:
[import]uid: 13099 topic_id: 26004 reply_id: 105320[/import]

Hey Nermion,

Sorry that other thread had 2 issues going and may have been a bit cluttered. I should have referenced the specific posting.

I had this same issue, adding return true will do the job. Good luck! [import]uid: 31262 topic_id: 26004 reply_id: 105339[/import]

thanks it helped and I learned something new about corona :slight_smile: [import]uid: 13099 topic_id: 26004 reply_id: 105352[/import]