My question is straightforward.
I have some ClickListener
s added to an Actor. I want to execute a click event on them programmatically.
Something like myActor.performClick()
;
I figured out a solution :
public static void performClick(Actor actor) {
Array<EventListener> listeners = actor.getListeners();
for(int i=0;i<listeners.size;i++)
{
if(listeners.get(i) instanceof ClickListener){
((ClickListener)listeners.get(i)).clicked(null, 0, 0);
}
}
}
This method can be called passing the actor on whom click needs to be performed