1
\$\begingroup\$

I can easily add listeners to the actors within a table, and they will fire events, but if I want an entire to table to have 1 listener and do not care to have differentiated effects depending on where it is touched, I want to be able to add the listener directly to the table. However, it is not firing, at all. I have turned on debug and tried pressing within the labels in the table or outside of them (still in the table, like on padding), but to no avail.

This is how I add the create the table:

il = new InfoListener();// extends ClickListener
info = new Table(skin);
info.setBackground("default-rect");
info.setVisible(false);
info.addListener(il);
info.setDebug(true);

// later on I have a method that adds things to the table
info.clear();
info.add(item.getDescription()).padRight(5);

info.setVisible(true);
info.setSize(info.getPrefWidth(), info.getPrefHeight());

It is a dynamic table (i.e. I change it's children when necessary), but that shouldn't make a difference. How do I have the table fire touch events?

\$\endgroup\$
0
\$\begingroup\$

Wow wow wow. So clear() removes all children, actions, and listeners...

All I needed to change was clear() to clearChildren()...

\$\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.