5 Replies Latest reply on Apr 26, 2010 5:04 AM by David_F57

    Drag Event Theory ?

    UbuntuPenguin Level 4

      Is there a way for a container placed below another container to still receive drag events.  For example , if you have a sprite on top of a list/hbox.  How can one make the entire space of the HBox respond to drag events.  Even though the sprite occludes its.

       

      Sincerely ,

        Ubu

        • 1. Re: Drag Event Theory ?
          David_F57 Level 5

          hi,

           

          Just so I understand what you want, are you trying to do something like this(the same can be applied with the drag manager). Even if you click on the inner box the drag is done with the parent.

           

          <?xml version="1.0" encoding="utf-8"?> 

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> 

          <mx:Script> 

          <![CDATA[ 

          import mx.controls.Alert;

          import mx.events.CloseEvent; 

           

          protected function canvas1_mouseDownHandler(event:MouseEvent):void

          {

          cnvs.startDrag();

          }

           

           

          protected function canvas1_mouseUpHandler(event:MouseEvent):void

          {

          cnvs.stopDrag();

          }

           

          ]]> 

          </mx:Script> 

          <mx:Canvas id="cnvs" width="200" height="200" x="349" y="182" borderStyle="solid" borderColor="#4392C9" cornerRadius="5" backgroundColor="#9C1C1C"

             mouseDown="canvas1_mouseDownHandler(event)"

             mouseUp="canvas1_mouseUpHandler(event)">

          <mx:Canvas x="10" y="10" width="134" height="105" borderStyle="none" backgroundColor="#0F1A7D">

          </mx:Canvas>

          </mx:Canvas>

          </mx:Application>

           

          David.

          • 2. Re: Drag Event Theory ?
            UbuntuPenguin Level 4

            Kind of , but not so much a parent->child relationship.  It's more of a situation where the children have the same parent , but the child with the draghandlers is at a lower index. , right now I am trying to experiment with cloning the drag event , and re-dispatching it since drag events don't bubble by default. Like this

             

                 <mx:Canvas height="100">
                        <mx:List x="0" y="0"  id="secondList"           //Canvas index of 0
                                 dragEnter="doDragEnter(event);"
                                 dragExit="doDragExit(event);"
                                 dragOver="doDragOver(event);"
                                 dragDrop="doDragDrop(event);"
                                 dragEnabled="true" height="100"/>      //Canvas index of 1
                        <mx:HBox id="badbox" x="0" y="0" width="{secondList.width}" height="100" backgroundColor="0xAAcccc" />
                    </mx:Canvas>

            • 3. Re: Drag Event Theory ?
              David_F57 Level 5

              hi,

               

              not sure why you would want to do this for but if the events are on the box it doesn't prevent you performing the operation on the list,

               

              for instance hbox you drop an image, in the dragdrop function you add the image to the listbox, but its the hbox that excepts the dragdrop event.

               

              David.

              • 4. Re: Drag Event Theory ?
                UbuntuPenguin Level 4

                But that's the thing if I have it correctly.  The DragEvent will hit the HBox first , because it is on top of the list.  Because it doesn't have a handler , you will get the "no drag" icon.  But DragEvent doesn't bubble to the parent container , much less to sibling containers.  Therefore , the drag event hits the HBox and bites the dust.  I think ....

                • 5. Re: Drag Event Theory ?
                  David_F57 Level 5

                  hi,

                   

                  the drag event ends when you release the mouse, if it can't 'focus' on a suitable target then of course there will be no drop event raised. Drag doesn't bubble because it is contrary to what drag and drop is, drag from one visible object to another visible object, hiding the drag recipient prevents it being a drag recipient. If you want the parent object to perform an action the 'box' or the 'list' or even both then you attach your drag operations to the parent itself. What you have explained has no fathomable value.

                   

                  David.