3 Replies Latest reply on Aug 16, 2010 10:24 AM by qw12er

    Drag n' droping only on HBox border ?!

    qw12er

      Hi,

       

      I've made a component extending a HBox and I want to drop a treeItem into that component. I've set the listeners onInit() and my component accept the drop ... but only on HBox borders or other components inside my HBox but somehow refuses the drop on the filling whitspace ?!

       

      How can I make my HBox accept drop on the white space filler ?!

       

      Thanks

        • 1. Re: Drag n' droping only on HBox border ?!
          VRPDeveloper Level 3

          You need to give your code over here... Its actually will not happen..so I guess something is missing in it...

           

           

          If this post answers your question or helps, please kindly mark it as such.

          • 2. Re: Drag n' droping only on HBox border ?!
            qw12er Level 1

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

            <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"

            paddingBottom="5"

            paddingLeft="5"

            paddingRight="5"

            paddingTop="10"

            borderStyle="solid"

            borderColor="#54809F"

            borderThickness="2"

            cornerRadius="5"

             

            initialize="init();"

            creationComplete="create();">

             

            <mx:Metadata>

            [Event(name='AddObjectEvent', type='msgEvent')]

            [Event(name='RemoveObjectEvent', type='msgEvent')]

            </mx:Metadata>

            <mx:Script>

            <![CDATA[

            import mx.utils.UIDUtil;

            import functions.DateManagement;

            import events.msgEvent;

            import functions.Utils;

            import mx.controls.Alert;

             

            // import for Drag n' drop

            import mx.core.DragSource;

            import mx.managers.DragManager;

            import mx.events.DragEvent;

            import mx.core.IUIComponent;

             

             

            [Bindable]

            public var UID:String = UIDUtil.createUID();

            public var xml:XML;

            public var isParent:Boolean;

             

             

             

            public function init():void{

            this.addEventListener(DragEvent.DRAG_ENTER, doDragEnter);

            this.addEventListener(DragEvent.DRAG_DROP, doDragDrop);

             

             

            //sets values

            if (xml != null){

            this.UID = xml.@id;

            this._name.text = xml.@name;

            this._type.selectedIndex = Utils.getDataTypeIndex(xml.@type);

            }

            }

             

             

            private function create():void{

            this.addEventListener('AddObjectEvent', addObject);

            this.addEventListener('RemoveObjectEvent', removeObject);

             

             

            // create children

            if (xml!=null){

            for each(var obj:XML in xml.children())

            this.addObjectFromXML(obj);

            }

             

            fillEmptyObj();

            this.xml = null;

            }

             

             

             

            // Check if drag proxy has format ...

            private function doDragEnter(event:DragEvent):void{

            if(event.dragSource.hasFormat('treeItems'))

            DragManager.acceptDragDrop(IUIComponent(event.target));

            }

             

             

            // Performs the drop op.

            private function doDragDrop(event:DragEvent):void{

            var items:Object = event.dragSource.dataForFormat("treeItems");

             

            for (var i:int=0; i<items.length; i++){

            Object(dataBox.getChildAt(i)).setRef(items[i].@id, items[i].localName());

            }

            }

             

             

             

            ]]>

            </mx:Script>

            <mx:Label id="no" fontWeight="bold"/>

            <mx:Label text="Name"/>

            <mx:TextInput width="125" id="_name"/>

            <mx:Label text="Type"/>

            <mx:ComboBox id="_type" editable="false" enabled="true" width="111">

            <mx:ArrayCollection>

                <mx:Object label="integer" data="int"/>

                <mx:Object label="float" data="float"/>

                <mx:Object label="String" data="string"/>

                <mx:Object label="date (dd/mm/yyyy)" data="date"/>

                </mx:ArrayCollection>

            </mx:ComboBox>

            <mx:VBox id="criteriaBox"/>

            <mx:VBox id="dataBox"/>

            </mx:HBox>