Event Propgation issue.

I have a ui.newButton that calls a function set on the onRelease property.

The function called, creates a new screen which happens to have a button in the same spot. That button however isn’t being built by ui.newButton, but simply and object with a basic event handler:

 selectButton:addEventListener("tap", buttonPressed)  

What appears to be happening is when I click on the button on the first screen, the second screen is created, but a tap event is sent to the second screen and I’m removing the screen before its displayed. That’s what debugging prints shows. I added a 100ms timer to the buttons on the 2nd screen so they don’t activate immediately and now it works like it should.

I *AM* doing a “return true” in the function called by onRelease so that event shouldn’t continue to propagate. Delaying the buttons becoming active is working, but its a nasty hack I’d like to avoid.

Any thoughts about why my tap event would get passed to the screen I’m creating?

Thanks
Rob
[import]uid: 19626 topic_id: 14027 reply_id: 314027[/import]

If your using director you may have this issue.

A solution is to create a full screen sized rectangle with display.newRect and set its alpha to 0.01 so its not really visible but also can receive touch events.

Create this upon tapping your button and insert it into the same group as your buttons. This will overlay everything on screen so nothing can be tapped between screen transitions and of course the rectangle will get removed along with your display group from the first screen after the transition has completed.

It’s still a work around of course, but it’s much easier to manage than delaying things :slight_smile: [import]uid: 84637 topic_id: 14027 reply_id: 51698[/import]