How do I cancel an event?

I’m looking for basic button functionality. I’m listening for touch events on buttons, but I’m also listening for touch events on Runtime. If a button receives an event, how do I prevent that event from bubbling up to Runtime by cancelling the event within the button’s touch listener? I want to simulate a “roll off” event. I want it so my Runtime touch listener responds to the “moved” phase and buttons respond to the “moved” phase but not both at the same time.

Hi Kyle,

Touches basically propagate first through the display object heirarchy, then if they’re not “handled” by anything there, they go to the Runtime. You can tell a touch to stop (not propagate further) by returning true in the button/object’s touch handler.

See here for a better description:

https://docs.coronalabs.com/guide/events/touchMultitouch/index.html#taptouch-propagation

Brent

Thanks! That works splendidly.

Hi Kyle,

Touches basically propagate first through the display object heirarchy, then if they’re not “handled” by anything there, they go to the Runtime. You can tell a touch to stop (not propagate further) by returning true in the button/object’s touch handler.

See here for a better description:

https://docs.coronalabs.com/guide/events/touchMultitouch/index.html#taptouch-propagation

Brent

Thanks! That works splendidly.