Packagecom.yworks.canvas.input
Interfacepublic interface IDragHandler
Implementors ConstrainedDragHandler

Interface for an object that can be used to drag something displayed in a CanvasComponent. Items can be dragged with the mouse and an instance of this class will modify their position accordingly. A drag will trigger the invocation of initializeDrag, zero or more handleMove calls and will be finalized by either dragFinished or cancelDrag.

See also

CanvasComponent
IPositionHandler
IHandle
IInputModeContext
initializeDrag
handleMove
dragFinished
cancelDrag


Public Properties
 PropertyDefined By
  x : Number
[read-only] Returns the x coordinate of the current position of the element.
IDragHandler
  y : Number
[read-only] Returns the y coordinate of the current position of the element.
IDragHandler
Public Methods
 MethodDefined By
  
cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void
Called by clients to indicate that the dragging has been canceled by the user.
IDragHandler
  
dragFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void
Called by clients to indicate that the repositioning has just been finished.
IDragHandler
  
handleMove(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):Boolean
Called by clients to indicate that the element has been dragged and its position should be updated.
IDragHandler
  
Called by clients to indicate that the element is going to be dragged.
IDragHandler
Property Detail
xproperty
x:Number  [read-only]

Returns the x coordinate of the current position of the element.

The point describes the current world coordinate position of the element. It is up to the implementation how this position is interpreted. The values returned by this method will be used for the "originalX" parameter in the handleMove, cancelDrag and dragFinished methods.


Implementation
    public function get x():Number
yproperty 
y:Number  [read-only]

Returns the y coordinate of the current position of the element.

The point describes the current world coordinate position of the element. It is up to the implementation how this position is interpreted. The values returned by this method will be used for the "originalY" parameter in the handleMove, cancelDrag and dragFinished methods.


Implementation
    public function get y():Number
Method Detail
cancelDrag()method
public function cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void

Called by clients to indicate that the dragging has been canceled by the user.

This method may be called after the initial initializeDrag and zero or more invocations of handleMove. Implementations should reset the position of the items they modify to their initial state. Alternatively to this method the dragFinished method might be called.

Parameters

context:IInputModeContext — The context to retrieve information about the drag from.
 
originalX:Number — The value of the x property at the time of initializeDrag.
 
originalY:Number — The value of the y property at the time of initializeDrag.

dragFinished()method 
public function dragFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void

Called by clients to indicate that the repositioning has just been finished. This method may be called after the initial initializeDrag and zero or more invocations of handleMove. Alternatively to this method the cancelDrag method might be called.

Parameters

context:IInputModeContext — The context to retrieve information about the drag from.
 
originalX:Number — The value of the x property at the time of initializeDrag.
 
originalY:Number — The value of the y property at the time of initializeDrag.
 
newX:Number — The value of the x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the x and y properties or may not be modified to reflect the new value. This is the same value as delivered in the last invocation of handleMove.
 
newY:Number — The value of the y coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the x and y properties or may not be modified to reflect the new value. This is the same value as delivered in the last invocation of handleMove.

handleMove()method 
public function handleMove(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):Boolean

Called by clients to indicate that the element has been dragged and its position should be updated.

This method may be called more than once after an initial initializeDrag and will be followed by either dragFinished or cancelDrag.

Parameters

context:IInputModeContext — The value of the x property at the time of initializeDrag.
 
originalX:Number — The value of the y property at the time of initializeDrag.
 
originalY:Number — The value of the x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the x property may or may not be modified to reflect the new value.
 
newX:Number — The value of the y coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the y property may or may not be modified to reflect the new value.
 
newY:Number

Returns
Boolean — Whether the move had any visual effect. This is a hint to the engine to optimize invalidation.
initializeDrag()method 
public function initializeDrag(context:IInputModeContext):void

Called by clients to indicate that the element is going to be dragged.

This call will be followed by one or more calls to handleMove, and a final dragFinished or cancelDrag.

Parameters

context:IInputModeContext — The context to retrieve information about the drag from.