public class DragAndDrop extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DragAndDrop.Payload
The payload of a drag and drop operation.
|
static class |
DragAndDrop.Source
A source where a payload can be dragged from.
|
static class |
DragAndDrop.Target
A target where a payload can be dropped to.
|
Constructor and Description |
---|
DragAndDrop() |
Modifier and Type | Method and Description |
---|---|
void |
addSource(DragAndDrop.Source source) |
void |
addTarget(DragAndDrop.Target target) |
void |
cancelTouchFocusExcept(DragAndDrop.Source except)
Cancels the touch focus for everything except the specified source.
|
void |
clear()
Removes all targets and sources.
|
Actor |
getDragActor()
Returns the current drag actor, or null.
|
DragAndDrop.Payload |
getDragPayload()
Returns the current drag payload, or null.
|
DragAndDrop.Source |
getDragSource()
Returns the current drag source, or null.
|
int |
getDragTime() |
boolean |
isDragging() |
boolean |
isDragValid()
Returns true if a drag is in progress and the
drag time has elapsed since the drag started. |
void |
removeSource(DragAndDrop.Source source) |
void |
removeTarget(DragAndDrop.Target target) |
void |
setButton(int button)
Sets the button to listen for, all other buttons are ignored.
|
void |
setCancelTouchFocus(boolean cancelTouchFocus)
When true (default), the
Stage.cancelTouchFocus() touch focus} is cancelled if
dragStart returns non-null. |
void |
setDragActorPosition(float dragActorX,
float dragActorY) |
void |
setDragTime(int dragMillis)
Time in milliseconds that a drag must take before a drop will be considered valid.
|
void |
setKeepWithinStage(boolean keepWithinStage) |
void |
setTapSquareSize(float halfTapSquareSize)
Sets the distance a touch must travel before being considered a drag.
|
void |
setTouchOffset(float touchOffsetX,
float touchOffsetY)
Sets an offset in stage coordinates from the touch position which is used to determine the drop location.
|
public void addSource(DragAndDrop.Source source)
public void removeSource(DragAndDrop.Source source)
public void addTarget(DragAndDrop.Target target)
public void removeTarget(DragAndDrop.Target target)
public void clear()
public void cancelTouchFocusExcept(DragAndDrop.Source except)
public void setTapSquareSize(float halfTapSquareSize)
public void setButton(int button)
Input.Buttons.LEFT
. Use -1 for any button.public void setDragActorPosition(float dragActorX, float dragActorY)
public void setTouchOffset(float touchOffsetX, float touchOffsetY)
public boolean isDragging()
@Null public DragAndDrop.Payload getDragPayload()
@Null public DragAndDrop.Source getDragSource()
public void setDragTime(int dragMillis)
public int getDragTime()
public boolean isDragValid()
drag time
has elapsed since the drag started.public void setCancelTouchFocus(boolean cancelTouchFocus)
Stage.cancelTouchFocus()
touch focus} is cancelled if
dragStart
returns non-null. This ensures the DragAndDrop is the only
touch focus listener, eg when the source is inside a ScrollPane
with flick scroll enabled.public void setKeepWithinStage(boolean keepWithinStage)
Copyright © 2020. All rights reserved.