8 Replies Latest reply on May 27, 2010 7:47 PM by Maxijin2

    Flex 4 : List Control Dragging issue

    Maxijin2 Level 1

      Hi

       

      Flex 4 List control doesnt allow me to drag an item unless it is selected. OR if i drag an unselected item from a s:List that item becomes selected.

       

      Is there any way i can drag an item without selecting it?

       

       

      <s:List dragEnabled="true"  change="list1_changeHandler(event)" dataProvider="{data}" itemRenderer="components.renderers.customRenderer"/>
      

       

       

      Thanks problem.jpg

        • 1. Re: Flex 4 : List Control Dragging issue
          Flex harUI Adobe Employee

          Doesn't Flex 3 List do the same thing?  I suppose you could detect a change

          to the selectedIndex if a drag-drop is in progress and restore the last

          selectedIndex.

          • 2. Re: Flex 4 : List Control Dragging issue
            Maxijin2 Level 1

            Flex 3 works as expected, Flex 3 doesnt select a list item if a dragndrop is in progress.

             

            I can detect a change in indexChangeEvent, but dont have any idea of detecting an in-progress Drag n Drop. I think indexChangeEvent occurs first.

             

            Any guidance?

            • 3. Re: Flex 4 : List Control Dragging issue
              Flex harUI Adobe Employee

              Try IndexChangeEvent.CHANGING to block selection and apply other logic to

              select later if no drag.

              • 4. Re: Flex 4 : List Control Dragging issue
                Maxijin2 Level 1

                But as you know that s:List dragEnabled=true automatically handle dragging, so i dont have any clue how to 'detect' if a dragging is in process? Can you kindly point me to its detection inside IndexChangeEvent.CHANGING handler?

                 

                Thanks

                • 5. Re: Flex 4 : List Control Dragging issue
                  Flex harUI Adobe Employee

                  I'm suggesting using IndexChangeEvent.CHANGING to block selection always,

                  and on mouseUp, set selection if there was no drag in between.  If you see a

                  DRAG_START event you know that a drag happened.

                  • 6. Re: Flex 4 : List Control Dragging issue
                    Maxijin2 Level 1

                    I blocked the selection using preventDefault() but now im not even able to initiate dragging.

                    Here is an example code

                     

                    <?xml version="1.0" encoding="utf-8"?>
                    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                      xmlns:s="library://ns.adobe.com/flex/spark" 
                                      xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
                         <fx:Script>
                              <![CDATA[
                                   import spark.events.IndexChangeEvent;
                    
                                   protected function list1_changingHandler(event:IndexChangeEvent):void
                                   {
                                        event.preventDefault();
                                   }
                    
                              ]]>
                         </fx:Script>
                         <fx:Declarations>
                              <!-- Place non-visual elements (e.g., services, value objects) here -->
                         </fx:Declarations>
                         <s:layout>
                              <s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/>
                         </s:layout>
                         
                         <s:List dragEnabled="true" changing="list1_changingHandler(event)">
                              <s:ArrayList>
                                   <fx:String>Item One</fx:String>
                                   <fx:String>Item Two</fx:String>
                                   <fx:String>Item Three</fx:String>
                                   <fx:String>Item Four</fx:String>
                              </s:ArrayList>
                         </s:List>
                         
                    </s:Application>
                    

                    • 7. Re: Flex 4 : List Control Dragging issue
                      Flex harUI Adobe Employee

                      I'm not clear what you are trying to accomplish. I tried dragging from an

                      mx:List and the thing I moused on and dragged got selected.

                      • 8. Re: Flex 4 : List Control Dragging issue
                        Maxijin2 Level 1

                        I'll make an example with s:List and mx:List and then i'll post here to clear my requirements tonight.

                        Thanks