Stage keeps propagating handled touch events
See original GitHub issueI just stumbled over this issue: http://gamedev.stackexchange.com/questions/106120/stopping-actor-tap-click-event-from-propagating
I believe this might be a bug in Stage
. Looking at its touchUp
handler (or any of the other handlers), it doesn’t appear to stop events from propagating when listeners handle it, since it makes no attempt to break out of the loop if Event#isHandled()
is true:
https://github.com/libgdx/libgdx/blob/2bd1557bc293cb8c2348374771aad832befbe26f/gdx/src/com/badlogic/gdx/scenes/scene2d/Stage.java#L348
This means that it’s impossible to receive click events in actors and swallow them in order to prevent them from triggering other game behavior in response to taps on the stage.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Controlling touch event propagation in case of overlapping ...
My current problem is that each card has a button and since relative card displacement is smaller than height of the button it...
Read more >Event Bubbling and Event Catching in JavaScript and React
Capturing Phase – The is first phase when an event is actually triggered. This event “captures” or propagates first through the topmost event ......
Read more >Event.stopPropagation() - Web APIs | MDN
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Read more >Bubbling and capturing - The Modern JavaScript Tutorial
The capturing phase is used very rarely, usually we handle events on bubbling. And there's a logical explanation for that.
Read more >The Dangers of Stopping Event Propagation - CSS-Tricks
This would allow event listeners registered farther up the DOM to inspect an event and, based on whether or not it had been...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, I assumed InputListener. The returning is done in
handle(Event)
method ofEventListener
.InputListener
returns whatever its (usually overriden)touchDown/Up/whatever
returned. ForActorGestureListener
this is slightly more complicated, because it does not support “not detecting gesture” and always returns true. Therefore, you will have to override thehandle()
method and add custom gesture-filtering logic.Explanations by @Darkyenus are correct.