Overlapping events

more like a feature request, not a bug.

you can new a issue to describe what you want. I don’t know if it’s proper to add this into cocos2d-x, but we can discuss this with other developers.

@drelaptop I don’t know how we can solve the problem, I said setting a button touch priority only as example, but I think I’m not the correct person for say what should be the solution.

If we view the problem from another point of view, I’m sure that it sounds more bug than feature. If the buttons behind are not overlapped the touch event in that buttons are disabled. But if the buttons are overlapped the events in the overlapped buttons behind are enabled. Why? It sounds like more bug than feature in this point of view.

But I repeat, i’m not the correct person for say what should be the solution, i’m only a programmer that uses the framework and I would like to have a good solution for my problem. If the team could check it, it would be good. Maybe i’m right, or maybe not.

Try addClickEventListener instead of addTouchEventListener.
And on parent of buttons call setTouchEnabled(false)

I think this should work.

@dimon4eg Thanks for ur advice.
If I use setTouchEnabled(false); in the behind button when I open the window, it works perfect. The events aren’t overlapped because only one is enabled.

Is a very easy patch, I will apply it. Thanks again :wink:

Great!
Please mark my answer as solution.

Ok, but this is not a solution, is a patch.
I would like to have a official answer of developers, hehehe.
Thanks

It’s not a patch!

Look:
image

if you click on blue area what will happen?

  1. after fix events order
    answer: the button under dialog will be clicked!

  2. after my fix
    answer: nothing, as expected

Actually I don’t think this is a patch. It is just using touch events to control what the director acts upon.

There may be a better way to handle it, but it feels ok until the developers act upon this in the future.

Before your fix, the behind button was clicked and that’s the error.
That button should be disabled if I’ve the window is opened.

If the buttons are not overlapped the behind buttons are disabled despite of I never used setTouchEnabled(false).
The point is why if the buttons are not overlapped, the behind buttons are disabled but if the buttons are overlapped not. That’s my main doubt.

Yep, thanks for your help too!

Did you try use addClickEventListener instead of addTouchEventListener ?

Yes, if i use in all buttons addClickEventListener i don’t need to disable touchs, etc.
Is a better solution.

But i hope you can understand the point that i described before :slight_smile:

Yup, you found solution but issue with events should be fixed I think.

Nice, you think the same as me then :stuck_out_tongue:

@tranthor thanks for this detail description, and congratulation on you found a solution.

I understood you just want a good solution for this problem, and hope the team could check it as soon as possible, but too many problems to check for the team, so I suggested to new a issue for this, and then other cocos2d-x developers will help you at issues tracker.

now I have new a issue for the problem, hope this will do some help.

1 Like