[flexcoders] DragDrop event propagation

2010-01-18 Thread txakin
Hi all,

I have a tree component with an xml file as dataprovider.
I would like to move node from one parent to other one, previously an alert 
message.

1.- I drag a node
2.- Before drop this node in new parent node, i want to display an alert 
message.
3.- If the user click YES, i want to move the node to the new parent
4.- If the user click NO, i want to cancel the drag and drop event.

Here is my source:

in the tree component i have the next properties:

dropEnabled=true
dragEnabled=true
dragMoveEnabled=true 
dragDrop=customDragDrop(event)   
allowMultipleSelection=false

The customDragDrop(event) function is:

import mx.events.DragEvent;
import mx.managers.DragManager;

private var queuedEvent:DragEvent;

private function customDragDrop(event:DragEvent): void
{
  //Get the data from the dragSource
  var items:Object = event.dragSource.dataForFormat(treeItems);
  event.stopPropagation();
  queuedEvent = event as DragEvent; 

  var messageText:String = Are you sure you want to move the node   
   + items[...@label.touppercase() + ?;
  var titleText:String = Warning;
  var alert:Alert = Alert.show(messageText, titleText, 
   Alert.NO | Alert.YES, 
   this, customDragDropHandler,alertIcon);
}

private function customDragDropHandler(event:CloseEvent):void{
  if (event.detail == Alert.NO){
queuedEvent.preventDefault();
queuedEvent.target.hideDropFeedback(queuedEvent);
DragManager.showFeedback(DragManager.NONE);
  }
  else {
dispatchEvent(queuedEvent); 
  } 
}

I don´t know why i can not get my solution, please i need your help.

Thanks in advance.



Re: [flexcoders] DragDrop event propagation

2010-01-18 Thread Alex Harui
I don’t think there is a way to refuse the drop when the dragDrop event occurs. 
 And especially if you want to pause for input.


On 1/18/10 4:19 AM, txakin txa...@yahoo.com wrote:






Hi all,

I have a tree component with an xml file as dataprovider.
I would like to move node from one parent to other one, previously an alert 
message.

1.- I drag a node
2.- Before drop this node in new parent node, i want to display an alert 
message.
3.- If the user click YES, i want to move the node to the new parent
4.- If the user click NO, i want to cancel the drag and drop event.

Here is my source:

in the tree component i have the next properties:

dropEnabled=true
dragEnabled=true
dragMoveEnabled=true
dragDrop=customDragDrop(event)
allowMultipleSelection=false

The customDragDrop(event) function is:

import mx.events.DragEvent;
import mx.managers.DragManager;

private var queuedEvent:DragEvent;

private function customDragDrop(event:DragEvent): void
{
 //Get the data from the dragSource
 var items:Object = event.dragSource.dataForFormat(treeItems);
 event.stopPropagation();
 queuedEvent = event as DragEvent;

 var messageText:String = Are you sure you want to move the node 
 + items[...@label.touppercase() + ?;
 var titleText:String = Warning;
 var alert:Alert = Alert.show(messageText, titleText,
 Alert.NO | Alert.YES,
   this, customDragDropHandler,alertIcon);
}

private function customDragDropHandler(event:CloseEvent):void{
 if (event.detail == Alert.NO){
 queuedEvent.preventDefault();
 queuedEvent.target.hideDropFeedback(queuedEvent);
 DragManager.showFeedback(DragManager.NONE);
 }
 else {
 dispatchEvent(queuedEvent);
 }
}

I don´t know why i can not get my solution, please i need your help.

Thanks in advance.






--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui