Package com.prineside.tdi2.scene2d.utils
Class DragAndDrop
java.lang.Object
com.prineside.tdi2.scene2d.utils.DragAndDrop
Manages drag and drop operations through registered drag sources and drop targets.
- Author:
- Nathan Sweet
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe payload of a drag and drop operation.static classA source where a payload can be dragged from.static classA target where a payload can be dropped to. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSource(DragAndDrop.Source source) voidaddTarget(DragAndDrop.Target target) voidCancels the touch focus for everything except the specified source.voidclear()Removes all targets and sources.Returns the current drag actor, or null.Returns the current drag payload, or null.Returns the current drag source, or null.intbooleanbooleanReturns true if a drag is in progress and thedrag timehas elapsed since the drag started.voidremoveSource(DragAndDrop.Source source) voidremoveTarget(DragAndDrop.Target target) voidsetButton(int button) Sets the button to listen for, all other buttons are ignored.voidsetCancelTouchFocus(boolean cancelTouchFocus) When true (default), theStage.cancelTouchFocus()touch focus} is cancelled ifdragStartreturns non-null.voidsetDragActorPosition(float dragActorX, float dragActorY) voidsetDragTime(int dragMillis) Time in milliseconds that a drag must take before a drop will be considered valid.voidsetKeepWithinStage(boolean keepWithinStage) voidsetTapSquareSize(float halfTapSquareSize) Sets the distance a touch must travel before being considered a drag.voidsetTouchOffset(float touchOffsetX, float touchOffsetY) Sets an offset in stage coordinates from the touch position which is used to determine the drop location.
-
Constructor Details
-
DragAndDrop
public DragAndDrop()
-
-
Method Details
-
addSource
-
removeSource
-
addTarget
-
removeTarget
-
clear
public void clear()Removes all targets and sources. -
cancelTouchFocusExcept
Cancels the touch focus for everything except the specified source. -
setTapSquareSize
public void setTapSquareSize(float halfTapSquareSize) Sets the distance a touch must travel before being considered a drag. -
setButton
public void setButton(int button) Sets the button to listen for, all other buttons are ignored. Default isInput.Buttons.LEFT. Use -1 for any button. -
setDragActorPosition
public void setDragActorPosition(float dragActorX, float dragActorY) -
setTouchOffset
public void setTouchOffset(float touchOffsetX, float touchOffsetY) Sets an offset in stage coordinates from the touch position which is used to determine the drop location. Default is 0,0. -
isDragging
public boolean isDragging() -
getDragActor
Returns the current drag actor, or null. -
getDragPayload
Returns the current drag payload, or null. -
getDragSource
Returns the current drag source, or null. -
setDragTime
public void setDragTime(int dragMillis) Time in milliseconds that a drag must take before a drop will be considered valid. This ignores an accidental drag and drop that was meant to be a click. Default is 250. -
getDragTime
public int getDragTime() -
isDragValid
public boolean isDragValid()Returns true if a drag is in progress and thedrag timehas elapsed since the drag started. -
setCancelTouchFocus
public void setCancelTouchFocus(boolean cancelTouchFocus) When true (default), theStage.cancelTouchFocus()touch focus} is cancelled ifdragStartreturns non-null. This ensures the DragAndDrop is the only touch focus listener, eg when the source is inside aScrollPanewith flick scroll enabled. -
setKeepWithinStage
public void setKeepWithinStage(boolean keepWithinStage)
-