3
\$\begingroup\$

According to the documentaton.

Adding a listener : Add a listener to receive events that hit this actor.

Adding a capture listener : Adds a listener that is only notified during the capture phase.

I was not successfully able to find information on this so called capture phase. What is the difference between both listeners? When should I use one over the other?

\$\endgroup\$
3
\$\begingroup\$

According to the official LibGDX wiki, capture listeners are called before "normal" listeners to give you a chance to intercept the events. (i.e. Active window cancels click on button under it)

First, during the "capture" phase an event is given to each actor from the root down to the target actor. Only capture listeners are notified during this phase. This gives parents a chance to intercept and potentially cancel events before children see them. Next, during the "normal" phase the event is given to each actor from the target up to the root. Only normal listeners are notified during this phase. This allows actors to handle an event themselves or let the parent have a try at it.

To intercept an event, you must return true in the capture listener so the event will be considered handled and will stop getting propagated.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.