The droptarget lists will receive DRAG_ENTER, DRAG_OVER, and DRAG_EXIT
events.  The DragEvent passed in contains a dragInitiator property which
points to the source of the drag.  You should implement handlers for
these events, and if the source is not the right one, call
DragManager.showFeedback(DragManager.NONE) and preventDefault() on the
event object.

 

-Alex

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of lruinelli
Sent: Sunday, March 18, 2007 11:57 AM
To: [email protected]
Subject: [flexcoders] question about drag & drop support in list-based
component

 

Hello!

...I developed a custom component named SwapList...to enable the user
to select a set of data from List dragging and dropping it to another
List.

Knowing the flex drag & drop support in list-based component...It
seems very simple...and easy to implement...but I have a problem...if
I put more SwapList component in a form...the user can drag a drop
items from every List of the from to every List of the form!! and I
don't find any work around to avoid nonsense drag and drop!:-(

are there any control which can be performed? 
or have I to implement all the drag and drop support manually?

...thanks for the help!

...pratical description:

the code of my component:

SwapList.mxml********************************
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " width="100%">
<mx:Script>
<![CDATA[
import mx.events.DragEvent;
import mx.managers.DragManager;
import mx.core.UIComponent;
import mx.core.DragSource; 

[Bindable]
public var _dataProvider: Object;
[Bindable] 
public var _labelField: String;

[Inspectable(defaultValue=null)]
public function set dataProvider(dataProvider:Object):void {
_dataProvider = dataProvider;
}

[Inspectable(defaultValue="")]
public function set labelField(labelField: String):void {
_labelField = labelField;
_labelField = labelField; 
} 
]]>
</mx:Script>

<mx:List width="300" id="listFrom" dragEnter="onDragEnter(event)"
dataProvider="{_dataProvider}" labelField="{_labelField}"
dropEnabled="true" dragMoveEnabled="true" dragEnabled="true"
height="74"></mx:List>

<mx:List width="300" id="listTo" dragEnter="onDragEnter(event)"
labelField="{_labelField}" dropEnabled="true" dragEnabled="true"
dragMoveEnabled="true" height="74"></mx:List>
</mx:HBox>

this component can be used in a form...as done in the following
extract of code (more SwapList in a form):

...
<mx:Form width="100%" height="100%">
<mx:FormItem label="Set of fruit:" width="100%"> 
<components:SwapList id="FruitSelecton" dataProvider="{fruits}" 
labelField="descr"/>
</mx:FormItem> 
<mx:FormItem label="Set of car:" width="100%">
<components:SwapList id="CarSelection" dataProvider="{cars}" 
labelField="dsecr"/> 
</mx:FormItem> 
</mx:Form>
...

...in this example user can drag a car from a List of available car
(in the SwapList CarSelection) and drop it in the List of selected
fruits! (in the SwapList FruitSelection) :-((( and my objective is
avoid this kind of selection (using some event to know if the dragged
item comes from the same instance of swaplist component e.g.)

THANKS

SALUTI
Lorenzo

 

Reply via email to