Example usage for com.badlogic.gdx.scenes.scene2d Actor addCaptureListener

List of usage examples for com.badlogic.gdx.scenes.scene2d Actor addCaptureListener

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d Actor addCaptureListener.

Prototype

public boolean addCaptureListener(EventListener listener) 

Source Link

Document

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

Usage

From source file:com.vlaaad.dice.ui.components.Hint.java

License:Open Source License

public static Hint make(final Actor actor, String locKey, ObjectMap<String, String> params) {
    final Hint result = new Hint(locKey, params);

    actor.addCaptureListener(new ActorGestureListener(20, 0.4f, 0.3f, 0.15f) {

        @Override//w ww  .j a  v  a  2 s .c  o  m
        public boolean longPress(Actor actor, float x, float y) {
            if (actor.getStage() == null)
                return false;
            actor.localToStageCoordinates(tmp.set(x, y));
            result.show(actor.getStage(), tmp.x, tmp.y);
            return false;
        }

        @Override
        public void pan(InputEvent event, float x, float y, float deltaX, float deltaY) {
            if (result.hide())
                event.cancel();
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (result.hide()) {
                event.cancel();
                if (actor.getStage() != null)
                    actor.getStage().cancelTouchFocus();
            }
        }
    });
    return result;
}