Packagecom.yworks.graph.input
Classpublic class NodeDropInputMode
InheritanceNodeDropInputMode Inheritance DropInputMode Inheritance AbstractConcurrentInputMode Inheritance AbstractInputMode Inheritance flash.events.EventDispatcher

A DropInputMode specialized to drag 'n' drop INodes. A dragged INode is visualized during the drag operation. The input mode does also support snapping of the dragged INode via the SnapContext.

The DropInputMode does not work properly together with the native drag manager in AIR applications. If problems occur the native drag manager can be disabled by setting useNativeDragManager to false in the WindowedApplication (since Flex 4).

See also

createDroppedNode


Public Properties
 PropertyDefined By
 Inheritedcanvas : CanvasComponent
[read-only] The canvas instance this mode is currently installed in or null
AbstractInputMode
 Inheritedcontroller : ConcurrencyController
Gets or injects the ConcurrencyController for this instance.
AbstractConcurrentInputMode
  dragNodeCreator : Function
Gets or sets the callback for drag node creation with has the signature: function (context:IInputModeContext, dragData:Object):INode with context The context for which the node should be created. dragData The node which should be dragged and is passed to the nodeDropCreator later. Can be set to a different value to implement a custom behavior.
NodeDropInputMode
 InheriteddropData : Object
[read-only] Gets the data carried by a drag operation.
DropInputMode
 InheriteddropLocation : IPoint
[read-only] Gets the mouse position after dropping an item.
DropInputMode
 Inheritedenabled : Boolean
Gets or sets the enabled state of this input mode.
AbstractConcurrentInputMode
  highlightedNode : INode
Adds a highlight to the given INode This is used for highlighting a group node when dragging over it.
NodeDropInputMode
 InheritedinputModeContext : IInputModeContext
[read-only] The context instance this mode is currently installed in or null if this instance is not installed.
AbstractInputMode
 Inheritedinstalled : Boolean
[read-only] Whether this mode is currently installed, i.e if a call to the canvas property will yield a non-null result.
AbstractInputMode
  isGroupNodePredicate : Function
Gets or sets the callback for testing whether a dragged node should be created as a group node. The function has to have the signature function(template:INode):Boolean The default implementation returns false always.
NodeDropInputMode
 InheritedmousePosition : IPoint
[read-only] Gets the current mouse position during drag operations.
DropInputMode
  nodeDropCreator : Function
Gets or sets the callback for node creation with has the signature: function (context:IInputModeContext, graph:IGraph, draggedNode:INode, newNodeLayout:IRectangle):INode with context The context for which the node should be created. graph The IGraph in which to create the node. draggedNode The node which should be created. newNodeLayout The layout of the node to be created. Can be set to a different value to implement a custom behavior.
NodeDropInputMode
 InheritedpreferredCursor : Cursor
Gets or sets the cursor this mode would like to have displayed in the CanvasComponent.
AbstractConcurrentInputMode
  showNodePreview : Boolean
Determines whether a preview of the dragged node is displayed during the drag.
NodeDropInputMode
  snapContext : SnapContext
The SnapContext which is used to snap the node during the drag.
NodeDropInputMode
  snappedMousePosition : IPoint
[read-only] Gets the current snapped mouse position during drag operations.
NodeDropInputMode
  snappingEnabled : Boolean
Switches snapping on and off.
NodeDropInputMode
 InheritedvalidDropHitTestable : IHitTestable
Gets or sets the IHitTestable that determines whether the given location is a valid drop location.
DropInputMode
Protected Properties
 PropertyDefined By
 InheriteddragSource : DragSource
[read-only] The DragSource object containing the data being dragged.
DropInputMode
Public Methods
 MethodDefined By
  
NodeDropInputMode(expectedDataFormat:String = INode, expectedDragImageFormat:String = IFlexDisplayObject)
Constructs a new instance of class DropInputMode for the expected data format.
NodeDropInputMode
  
cancel():void
[override] Cleanly cancels this mode.
NodeDropInputMode
 Inherited
dispose():void
Disposes this input mode.
AbstractInputMode
 Inherited
Installs this mode into the canvas of the given context.
AbstractInputMode
 Inherited
stop():Boolean
[override] Returns true if this input mode doesn't own the mutex.
AbstractConcurrentInputMode
 Inherited
Uninstalls this mode from the canvas.
AbstractInputMode
Protected Methods
 MethodDefined By
 Inherited
acceptDragEnter(e:DragEvent):Boolean
Callback that returns if the current drag may be accepted.
DropInputMode
 Inherited
canRequestMutex():Boolean
Determines whether this instance can request the InputMutex.
AbstractConcurrentInputMode
 Inherited
Callback that updates the drag location upon view point changes of the CanvasComponent into which this input mode is installed.
DropInputMode
  
[override] This method is called by cancel and after a onDragDrop to cleanup any internal state.
NodeDropInputMode
  
Callback registered on the SnapContext that collects SnapResults for the dragged node.
NodeDropInputMode
 Inherited
dataForFormat(format:String):Object
Gets the data carried by a drag operation that has been registered with the given format.
DropInputMode
 Inherited
AbstractInputMode
 Inherited
AbstractInputMode
 Inherited
AbstractInputMode
 Inherited
AbstractInputMode
  
Gets the currently dragged INode instance.
NodeDropInputMode
  
Looks for a group node in the drop location.
NodeDropInputMode
  
getNodeLayout(x:Number, y:Number, width:Number, height:Number):IRectangle
Calculates the layout of the new node.
NodeDropInputMode
 Inherited
hasMutex():Boolean
Determines whether this instance owns the input mutex.
AbstractConcurrentInputMode
  
Hides the drag image.
NodeDropInputMode
 Inherited
initialize():void
Performs one-time initialization of this instance.
AbstractInputMode
 Inherited
[override] Installs this mode into the given canvas.
DropInputMode
 Inherited
invalidate():void
Convenience method for subclass implementations that invalidates the canvasComponent this mode is currently installed in.
AbstractInputMode
 Inherited
onDisabled():void
[override] Called when the AbstractConcurrentInputMode.enabled property changes to false.
DropInputMode
  
onDragDrop(e:DragEvent):void
[override] Called whenever a drag is over the canvas.
NodeDropInputMode
  
onDragEnter(e:DragEvent):void
[override] Called once a drag has entered the canvas.
NodeDropInputMode
  
onDragExit(e:DragEvent):void
[override] Called whenever a drag is over the canvas.
NodeDropInputMode
 Inherited
onDragOver(e:DragEvent):void
Called whenever a drag is over the canvas.
DropInputMode
 Inherited
onEnabled():void
[override] Called when the AbstractConcurrentInputMode.enabled property changes to true.
DropInputMode
 Inherited
Called when this instance obtains the InputMutex.
AbstractConcurrentInputMode
 Inherited
Called when this instance released the InputMutex.
AbstractConcurrentInputMode
  
Called whenever a new node is created
NodeDropInputMode
 Inherited
onPreferredCursorChanged(oldValue:Cursor, newValue:Cursor):void
Called when the preferredCursor property changes.
AbstractConcurrentInputMode
 Inherited
Releases the mutex that is currently owned by this instance.
AbstractConcurrentInputMode
 Inherited
Requests the InputMutex from the current controller.
AbstractConcurrentInputMode
 Inherited
setAccepting(accept:Boolean):void
Tell the DragManager to accept canvas as drop target or sets the drop target to null.
DropInputMode
  
setDragLocation(coordinates:IPoint):void
[override] Sets the drag location and updates the layout of the dragged node based on the mouse coordinates and the results of the SnapContext.
NodeDropInputMode
  
Shows the previously hidden drag image.
NodeDropInputMode
 Inherited
[override] Uninstalls this mode from the canvas.
DropInputMode
Events
 Event Summary Defined By
 InheritedThis event is raised, if a drag operation is dropped onto the CanvasComponent into which this instance is installed.DropInputMode
 InheritedThis event is raised, if a drag operation enters the CanvasComponent into which this instance is installed.DropInputMode
 InheritedThis event is raised, if a drag operation leaves the CanvasComponent into which this instance is installed.DropInputMode
 InheritedThis event is raised, if a drag operation drags over the CanvasComponent into which this instance is installed.DropInputMode
 InheritedDispatched after the input mode was installed.AbstractInputMode
 InheritedDispatched before the input mode will be installed.AbstractInputMode
  Fired if a new node gets created by this input mode.NodeDropInputMode
 InheritedDispatched when the default cursor changed.AbstractConcurrentInputMode
 InheritedDispatched after the input mode was uninstalled.AbstractInputMode
 InheritedDispatched before the input mode will be uninstalled.AbstractInputMode
Public Constants
 ConstantDefined By
 InheritedINSTALLED : String = installed
[static]
AbstractInputMode
 InheritedINSTALLING : String = installing
[static]
AbstractInputMode
 InheritedPREFERRED_CURSOR_CHANGED : String = preferredCursorChanged
[static]
AbstractConcurrentInputMode
 InheritedUNINSTALLED : String = uninstalled
[static]
AbstractInputMode
 InheritedUNINSTALLING : String = uninstalling
[static]
AbstractInputMode
Property Detail
dragNodeCreatorproperty
dragNodeCreator:Function

Gets or sets the callback for drag node creation with has the signature: function (context:IInputModeContext, dragData:Object):INode with

Can be set to a different value to implement a custom behavior. The default implementation just delegates to getDraggedNode


Implementation
    public function get dragNodeCreator():Function
    public function set dragNodeCreator(value:Function):void

See also

highlightedNodeproperty 
highlightedNode:INode

Adds a highlight to the given INode This is used for highlighting a group node when dragging over it.


Implementation
    public function get highlightedNode():INode
    public function set highlightedNode(value:INode):void
isGroupNodePredicateproperty 
isGroupNodePredicate:Function

Gets or sets the callback for testing whether a dragged node should be created as a group node. The function has to have the signature function(template:INode):Boolean

The default implementation returns false always. Can be set to a different value to implement custom group node detection.


Implementation
    public function get isGroupNodePredicate():Function
    public function set isGroupNodePredicate(value:Function):void
nodeDropCreatorproperty 
nodeDropCreator:Function

Gets or sets the callback for node creation with has the signature: function (context:IInputModeContext, graph:IGraph, draggedNode:INode, newNodeLayout:IRectangle):INode with

Can be set to a different value to implement a custom behavior.


Implementation
    public function get nodeDropCreator():Function
    public function set nodeDropCreator(value:Function):void
showNodePreviewproperty 
showNodePreview:Boolean

Determines whether a preview of the dragged node is displayed during the drag. If the drag image had been added to the DragSource, it is hidden while the preview is displayed.

The default value is true.


Implementation
    public function get showNodePreview():Boolean
    public function set showNodePreview(value:Boolean):void
snapContextproperty 
snapContext:SnapContext

The SnapContext which is used to snap the node during the drag. If set to null (the default) this input mode tries to obtain the SnapContext from the IInputModeContext. To explicitly disable snapping, a VoidSnapContext has to be set to this instance.

The default value is null.


Implementation
    public function get snapContext():SnapContext
    public function set snapContext(value:SnapContext):void
snappedMousePositionproperty 
snappedMousePosition:IPoint  [read-only]

Gets the current snapped mouse position during drag operations. The position is returned in world coordinates according to the CanvasComponent into which this input mode is installed.


Implementation
    public function get snappedMousePosition():IPoint
snappingEnabledproperty 
snappingEnabled:Boolean

Switches snapping on and off.

The default value is true.


Implementation
    public function get snappingEnabled():Boolean
    public function set snappingEnabled(value:Boolean):void
Constructor Detail
NodeDropInputMode()Constructor
public function NodeDropInputMode(expectedDataFormat:String = INode, expectedDragImageFormat:String = IFlexDisplayObject)

Constructs a new instance of class DropInputMode for the expected data format.

Parameters
expectedDataFormat:String (default = INode) — The expected data format for the drag operation.
 
expectedDragImageFormat:String (default = IFlexDisplayObject) — The format the drag image is added to the DragSource. This format is used to hide the drag image if an preview of the dragged node is displayed.

See also

Method Detail
cancel()method
override public function cancel():void

Cleanly cancels this mode.

cleanupDrag()method 
override protected function cleanupDrag():void

This method is called by cancel and after a onDragDrop to cleanup any internal state.

collect()method 
protected function collect(evt:CollectSnapResultEvent):void

Callback registered on the SnapContext that collects SnapResults for the dragged node.

This method does use the INodeSnapResultProvider registered in the node's lookup or NodeSnapResultProvider.instance if no such provider could be found.

Parameters

evt:CollectSnapResultEvent — The event describing the movement SnapResults shall be collected for.

getDraggedNode()method 
protected function getDraggedNode():INode

Gets the currently dragged INode instance. The method is called by the dragNodeCreator. This implementation simply tries to cast the DropInputMode.dropData to INode.

Returns
INode — Ehe currently dragged INode instance.
getDropTargetParentNode()method 
protected function getDropTargetParentNode(groupedGraph:IGroupedGraph):INode

Looks for a group node in the drop location. If there are several nested group nodes the innermost is returned.

Parameters

groupedGraph:IGroupedGraph — The IGroupedGraph in which to look for.

Returns
INode — A group node or null if no group was found at the droop location.
getNodeLayout()method 
protected function getNodeLayout(x:Number, y:Number, width:Number, height:Number):IRectangle

Calculates the layout of the new node. In this implementation the mouse location is used as center of the node. Can be overridden in child class to implement a different layout.

Parameters

x:Number — The current horizontal mouse position.
 
y:Number — The current vertical mouse position.
 
width:Number — The width of the node.
 
height:Number — The height of the node.

Returns
IRectangle — A rectangle with the given size and the mouse location as center.
hideDragImage()method 
protected function hideDragImage():void

Hides the drag image. This method is called when a node preview is displayed.

See also

onDragDrop()method 
override protected function onDragDrop(e:DragEvent):void

Called whenever a drag is over the canvas.

Parameters

e:DragEvent — The drag event with type DragEvent.DRAG_DROP.

onDragEnter()method 
override protected function onDragEnter(e:DragEvent):void

Called once a drag has entered the canvas.

Parameters

e:DragEvent — The drag event with type DragEvent.DRAG_ENTER.

onDragExit()method 
override protected function onDragExit(e:DragEvent):void

Called whenever a drag is over the canvas.

Parameters

e:DragEvent — The drag event with type DragEvent.DRAG_EXIT.

onNodeCreated()method 
protected function onNodeCreated(evt:NodeDropEvent):void

Called whenever a new node is created

Parameters

evt:NodeDropEvent — The NodeDropEvent that gets dispatched.

setDragLocation()method 
override protected function setDragLocation(coordinates:IPoint):void

Sets the drag location and updates the layout of the dragged node based on the mouse coordinates and the results of the SnapContext.

Parameters

coordinates:IPoint — The mouse coordinates used to set the drag location.

See also

DropInputMode.setDragLocation
getDraggedNode
showDragImage()method 
protected function showDragImage():void

Shows the previously hidden drag image.

See also

Event Detail
nodeCreated Event
Event Object Type: com.yworks.graph.input.NodeDropEvent
NodeDropEvent.type property = com.yworks.graph.input.NodeDropEvent.NODE_CREATED

Fired if a new node gets created by this input mode.

Dispatched when a new node has been created.