Package arc.scene.event
Class DragListener
java.lang.Object
arc.scene.event.InputListener
arc.scene.event.DragListener
- All Implemented Interfaces:
EventListener
- Direct Known Subclasses:
DragScrollListener
Detects mouse or finger touch drags on an element. A touch must go down over the element 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.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
void
drag
(InputEvent event, float x, float y, int pointer) void
dragStart
(InputEvent event, float x, float y, int pointer) void
dragStop
(InputEvent event, float x, float y, int pointer) int
float
Returns the amount on the x axis that the touch has been dragged since the last drag event.float
Returns the amount on the y axis that the touch has been dragged since the last drag event.float
float
float
float
float
boolean
Returns true if a touch has been dragged outside the tap square.void
setButton
(int button) Sets the button to listen for, all other buttons are ignored.void
setTapSquareSize
(float halfTapSquareSize) boolean
touchDown
(InputEvent event, float x, float y, int pointer, int button) void
touchDragged
(InputEvent event, float x, float y, int pointer) 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.void
touchUp
(InputEvent event, float x, float y, int pointer, int button)
-
Constructor Details
-
DragListener
public DragListener()
-
-
Method Details
-
touchDown
-
touchDragged
Description copied from class:InputListener
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 alwayshandled
.- Overrides:
touchDragged
in classInputListener
- See Also:
-
touchUp
-
dragStart
-
drag
-
dragStop
-
cancel
public void cancel() -
isDragging
public boolean isDragging()Returns true if a touch has been dragged outside the tap square. -
getTapSquareSize
public float getTapSquareSize() -
setTapSquareSize
public void setTapSquareSize(float halfTapSquareSize) -
getTouchDownX
public float getTouchDownX() -
getTouchDownY
public float getTouchDownY() -
getStageTouchDownX
public float getStageTouchDownX() -
getStageTouchDownY
public float getStageTouchDownY() -
getDeltaX
public float getDeltaX()Returns the amount on the x axis that the touch has been dragged since the last drag event. -
getDeltaY
public float getDeltaY()Returns the amount on the y axis that the touch has been dragged since the last drag event. -
getButton
public int getButton() -
setButton
public void setButton(int button) Sets the button to listen for, all other buttons are ignored. Default isButtons#LEFT
. Use -1 for any button.
-