Last Updated: July 01, 2019
· exallium

Gestures on a Table in LibGDX...

This took me longer than I care to admit.

1) Extend ActorGestureListener and implement whichever events you want

2) Set this as a listener on your table with addListener(..)

3) Use setTouchable(..) to set table to Touchable.enabled

4) Set the bounding box using setBounds(x, y, w, h)

5) Profit!


class MyGestureListener extends ActorGestureListener {

    public void fling(InputEvent event, float velocityX, float velocityY, int button) {
        // Do stuff...

// Later on
Table myTable = new Table();
myTable.addListener(new MyGestureListener());
myTable.setBounds(x, y, w, h);

// Even Later.... PROFIT...