Packagecom.yworks.canvas.input
Classpublic class ConstrainedDragHandler
InheritanceConstrainedDragHandler Inheritance Object
Implements IDragHandler
Subclasses ConstrainedHandle

A utility implementation of the IDragHandler interface that can be used to constrain the movement of an existing instance conveniently.



Public Properties
 PropertyDefined By
  delegateHandler : IDragHandler
[read-only] Gets the delegate handler to which calls will be ultimately delegated.
ConstrainedDragHandler
  x : Number
[read-only] Delegates to the delegateHandler's IDragHandler.x property.
ConstrainedDragHandler
  y : Number
[read-only] Delegates to the delegateHandler's IDragHandler.y property.
ConstrainedDragHandler
Public Methods
 MethodDefined By
  
Initializes a new instance of the ConstrainedDragHandler class that delegates to the wrappedHandler.
ConstrainedDragHandler
  
cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void
Cancels the move operation and calls onCanceled.
ConstrainedDragHandler
  
dragFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void
Handles the finish operation and invokes onFinished.
ConstrainedDragHandler
  
handleMove(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):Boolean
Handles the move operation and subsequently calls onMoved.
ConstrainedDragHandler
  
Initializes the drag operation and subsequently calls onInitialized.
ConstrainedDragHandler
Protected Methods
 MethodDefined By
  
constrainNewLocation(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):IPoint
Callback that needs to implement the constraints for the new location.
ConstrainedDragHandler
  
onCanceled(context:IInputModeContext, originalX:Number, originalY:Number):void
Called when the cancelDrag method has been called.
ConstrainedDragHandler
  
onFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void
Called when the dragFinished method has been called.
ConstrainedDragHandler
  
onInitialized(context:IInputModeContext, originalX:Number, originalY:Number):void
Called when the initializeDrag method has been called.
ConstrainedDragHandler
  
onMoved(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void
Called when the handleMove operation has been performed.
ConstrainedDragHandler
Property Detail
delegateHandlerproperty
delegateHandler:IDragHandler  [read-only]

Gets the delegate handler to which calls will be ultimately delegated.


Implementation
    public function get delegateHandler():IDragHandler
xproperty 
x:Number  [read-only]

Delegates to the delegateHandler's IDragHandler.x property.


Implementation
    public function get x():Number

See also

yproperty 
y:Number  [read-only]

Delegates to the delegateHandler's IDragHandler.y property.


Implementation
    public function get y():Number

See also

Constructor Detail
ConstrainedDragHandler()Constructor
public function ConstrainedDragHandler(wrappedHandler:IDragHandler)

Initializes a new instance of the ConstrainedDragHandler class that delegates to the wrappedHandler.

Parameters
wrappedHandler:IDragHandler — The handler to delegate to.
Method Detail
cancelDrag()method
public function cancelDrag(context:IInputModeContext, originalX:Number, originalY:Number):void

Cancels the move operation and calls onCanceled.

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.

constrainNewLocation()method 
protected function constrainNewLocation(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):IPoint

Callback that needs to implement the constraints for the new location.

Parameters

context:IInputModeContext — The context in which the drag will be performed.
 
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 x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the location may or may not be modified to reflect the new value.
 
newY:Number — The x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the location may or may not be modified to reflect the new value.

Returns
IPoint — The constrained value of newX and newY.
dragFinished()method 
public function dragFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void

Handles the finish operation and invokes onFinished.

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 x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the location may or may not be modified to reflect the new value. This is the same value as delivered in the last invocation of handleMove.
 
newX:Number — The x coordinate in the world coordinate system that the client wants the handle to be at. Depending on the implementation the location may 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

See also

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

Handles the move operation and subsequently calls onMoved. This method will use the constrainNewLocation callback to let subclasses constrain the movement.

Parameters

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

Returns
Boolean — Whether the move had any visual effect. This is a hint to the engine to optimize invalidation.

See also

initializeDrag()method 
public function initializeDrag(context:IInputModeContext):void

Initializes the drag operation and subsequently calls onInitialized.

Parameters

context:IInputModeContext — The context in which the drag will be performed.

onCanceled()method 
protected function onCanceled(context:IInputModeContext, originalX:Number, originalY:Number):void

Called when the cancelDrag method has been called.

Parameters

context:IInputModeContext — The input mode context.
 
originalX:Number — The original horizontal location.
 
originalY:Number — The original vertical location

See also

onFinished()method 
protected function onFinished(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void

Called when the dragFinished method has been called.

Parameters

context:IInputModeContext — The input mode context.
 
originalX:Number — The original horizontal location.
 
originalY:Number — The original vertical location
 
newX:Number — The new horizontal location.
 
newY:Number — The new vertical location.

See also

onInitialized()method 
protected function onInitialized(context:IInputModeContext, originalX:Number, originalY:Number):void

Called when the initializeDrag method has been called.

Parameters

context:IInputModeContext — The input mode context.
 
originalX:Number — The original horizontal location.
 
originalY:Number — The original vertical location

See also

onMoved()method 
protected function onMoved(context:IInputModeContext, originalX:Number, originalY:Number, newX:Number, newY:Number):void

Called when the handleMove operation has been performed.

Parameters

context:IInputModeContext — The input mode context.
 
originalX:Number — The original horizontal location.
 
originalY:Number — The original vertical location
 
newX:Number — The new horizontal location.
 
newY:Number — The new vertical location.

See also