Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
<components:WidgetModule xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:components="com.ikanow.infinit.e.widget.library.components.*"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx" 
    implements="com.ikanow.infinit.e.widget.library.widget.IWidget"
    widgetDrop="widgetmodule1_widgetDropHandler(event)">
	
	<fx:Script>
        <![CDATA[
			import com.ikanow.infinit.e.widget.library.events.WidgetDropEvent;

			protected function widgetmodule1_widgetDropHandler(event:WidgetDropEvent):void
            {                
                trace("Ents: " + event.entities.length);
                trace("Assocs: " + event.associations.length);
                trace("Docs: " + event.documents.length);
                trace("Source: " + event.dragSource);
                trace("WidgetName: " + event.dragWidgetName);
                trace("WidgetClass: " + event.dragWidgetClass);               
            }
		]]>
    </fx:Script>
</components:WidgetModule>

The WidgetDropEvent object holds 3 anonymous arrays: entities,associations,documents, any/all of these may have data in them.
It also holds some information on where the drag came from:
dragSource: the dragger manually specifies this, can be anything
dragWidgetName: the title of the widget the drag came from
dragWidgetClass: the class of the widget the drag came from (i.e. the mxml file name of WidgetModule)

 

To send dragged items to another widget, dispatch an drag event with the dataformat using WidgetDragUtil.WIDGET_DRAG_FORMAT:

Code Block
protected function widgetheaderdragimage1_mouseDownHandler(event:MouseEvent):void
{
	var docs:Array = new Array();
	for each ( var doc:Object in docList.selectedItems )
	{                    
		docs.push(doc);
	}                
	var dragObject:WidgetDragObject = new WidgetDragObject();
	dragObject.documents = new ArrayCollection(docs);
	dragObject.dragSource = "MyCustomWidgetName";  //this is the user made drag name, can be anything               
	var ds:DragSource = new DragSource();
	ds.addData(dragObject, WidgetDragUtil.WIDGET_DRAG_FORMAT );           
	DragManager.doDrag(dragImage, ds, event);
}

...