APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.scenes.scene2d.utils

public Class DragListener

extends InputListener
Class Inheritance
Known Direct Subclasses
com.badlogic.gdx.scenes.scene2d.utils.DragScrollListener
Imports
com.badlogic.gdx.Input.Buttons, com.badlogic.gdx.math.Vector2, com.badlogic.gdx.scenes.scene2d.InputEvent, .InputListener

Detects mouse or finger touch drags on an actor. A touch must go down over the actor and a drag won't start until it is moved outside the tap square. Any touch (not just the first) will trigger this listener. While pressed, other touch downs are ignored.
Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private int
private boolean
private float
private float
private float
private float
private float
private float
private int
private float
private float
private float
private float
private float

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
drag(InputEvent event, float x, float y, int pointer)

public void
dragStart(InputEvent event, float x, float y, int pointer)

public void
dragStop(InputEvent event, float x, float y, int pointer)

public int
public float
getDeltaX()

Returns the amount on the x axis that the touch has been dragged since the last drag event.

public float
getDeltaY()

Returns the amount on the y axis that the touch has been dragged since the last drag event.

public float
getDragDistance()

The distance from drag start to the current drag position.

public float
public float
public float
public float
public float
public float
public float
public float
public float
public boolean
isDragging()

Returns true if a touch has been dragged outside the tap square.

public void
setButton(int button)

Sets the button to listen for, all other buttons are ignored.

public void
setDragStartX(float dragStartX)

public void
setDragStartY(float dragStartY)

public void
setTapSquareSize(float halfTapSquareSize)

public boolean
touchDown(InputEvent event, float x, float y, int pointer, int button)

Overrides com.badlogic.gdx.scenes.scene2d.InputListener.touchDown.

Called when a mouse button or a finger touch goes down on the actor.

public void
touchDragged(InputEvent event, float x, float y, int pointer)

Overrides com.badlogic.gdx.scenes.scene2d.InputListener.touchDragged.

Called when a mouse button or a finger touch is moved anywhere, but only if touchDown previously returned true for the mouse button or touch.

public void
touchUp(InputEvent event, float x, float y, int pointer, int button)

Overrides com.badlogic.gdx.scenes.scene2d.InputListener.touchUp.

Called when a mouse button or a finger touch goes up anywhere, but only if touchDown previously returned true for the mouse button or touch.

Inherited from com.badlogic.gdx.scenes.scene2d.InputListener:
enterexithandlekeyDownkeyTypedkeyUpmouseMovedscrolled

Field Detail

buttonback to summary
private int button
draggingback to summary
private boolean dragging
dragLastXback to summary
private float dragLastX
dragLastYback to summary
private float dragLastY
dragStartXback to summary
private float dragStartX
dragStartYback to summary
private float dragStartY
dragXback to summary
private float dragX
dragYback to summary
private float dragY
pressedPointerback to summary
private int pressedPointer
stageTouchDownXback to summary
private float stageTouchDownX
stageTouchDownYback to summary
private float stageTouchDownY
tapSquareSizeback to summary
private float tapSquareSize
touchDownXback to summary
private float touchDownX
touchDownYback to summary
private float touchDownY

Constructor Detail

DragListenerback to summary
public DragListener()

Method Detail

cancelback to summary
public void cancel()
dragback to summary
public void drag(InputEvent event, float x, float y, int pointer)
dragStartback to summary
public void dragStart(InputEvent event, float x, float y, int pointer)
dragStopback to summary
public void dragStop(InputEvent event, float x, float y, int pointer)
getButtonback to summary
public int getButton()
getDeltaXback to summary
public float getDeltaX()

Returns the amount on the x axis that the touch has been dragged since the last drag event.

getDeltaYback to summary
public float getDeltaY()

Returns the amount on the y axis that the touch has been dragged since the last drag event.

getDragDistanceback to summary
public float getDragDistance()

The distance from drag start to the current drag position.

getDragStartXback to summary
public float getDragStartX()
getDragStartYback to summary
public float getDragStartY()
getDragXback to summary
public float getDragX()
getDragYback to summary
public float getDragY()
getStageTouchDownXback to summary
public float getStageTouchDownX()
getStageTouchDownYback to summary
public float getStageTouchDownY()
getTapSquareSizeback to summary
public float getTapSquareSize()
getTouchDownXback to summary
public float getTouchDownX()
getTouchDownYback to summary
public float getTouchDownY()
isDraggingback to summary
public boolean isDragging()

Returns true if a touch has been dragged outside the tap square.

setButtonback to summary
public void setButton(int button)

Sets the button to listen for, all other buttons are ignored. Default is Buttons#LEFT. Use -1 for any button.

setDragStartXback to summary
public void setDragStartX(float dragStartX)
setDragStartYback to summary
public void setDragStartY(float dragStartY)
setTapSquareSizeback to summary
public void setTapSquareSize(float halfTapSquareSize)
touchDownback to summary
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)

Overrides com.badlogic.gdx.scenes.scene2d.InputListener.touchDown.

Doc from com.badlogic.gdx.scenes.scene2d.InputListener.touchDown.

Called when a mouse button or a finger touch goes down on the actor. If true is returned, this listener will have touch focus, so it will receive all touchDragged and touchUp events, even those not over this actor, until touchUp is received. Also when true is returned, the event is handled.

touchDraggedback to summary
public void touchDragged(InputEvent event, float x, float y, int pointer)

Overrides com.badlogic.gdx.scenes.scene2d.InputListener.touchDragged.

Doc from com.badlogic.gdx.scenes.scene2d.InputListener.touchDragged.

Called when a mouse button or a finger touch is moved anywhere, but only if touchDown previously returned true for the mouse button or touch. The touchDragged event is always handled.

touchUpback to summary
public void touchUp(InputEvent event, float x, float y, int pointer, int button)

Overrides com.badlogic.gdx.scenes.scene2d.InputListener.touchUp.

Doc from com.badlogic.gdx.scenes.scene2d.InputListener.touchUp.

Called when a mouse button or a finger touch goes up anywhere, but only if touchDown previously returned true for the mouse button or touch. The touchUp event is always handled.