0 Replies Latest reply on Dec 7, 2011 12:42 AM by chrisdelambert

    TextInput drag and drop help

    chrisdelambert

      Hi all, I have a question about dragging and dropping a text input field.

       

      I have two textinputfields, and when I ctrl click, I want to drag them to a new location. This part works, however when I click in the textinputfields after I have dragged them they snap back to their original location.

       

      This is so frustrating! Can someone explain this behaviour to me? I want the textfields to stay where I dragged them! PLease help!

       

      Flash builder code below

       

      <?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"

                                       creationComplete="init()">

                <fx:Script>

                          <![CDATA[

                                    protected function init():void

                                    {

       

                                    }

       

                                    protected function dragText(e:MouseEvent):void

                                    {

                                              if(e.ctrlKey)

                                              {

                                                        e.target.startDrag();

                                              }

                                    }

                                    protected function releaseText(e:MouseEvent):void

                                    {

                                              e.target.stopDrag();

                                              e.target.x = e.target.x;

                                              e.target.y = e.target.y;

                                    }

       

       

                          ]]>

                </fx:Script>

                <fx:Declarations>

                          <!-- Place non-visual elements (e.g., services, value objects) here -->

                </fx:Declarations>

                <s:BorderContainer id="bannerContent" width="100%" height="100%" borderVisible="false">

                          <s:backgroundFill>

                                    <s:LinearGradient rotation="90">

                                              <s:GradientEntry id="backTopColor" color="#000000"/>

                                              <s:GradientEntry id="backBottomColor" color="#000000"/>

                                    </s:LinearGradient>

                          </s:backgroundFill>

       

       

                                    <s:TextInput y="51" x="21" color="#FFFFFF" text="Drag Me Around" borderVisible="false" contentBackgroundAlpha="0.0" fontSize="80" toolTip="Click text to edit, CTRL + click to move" mouseDown="dragText(event)" mouseUp="releaseText(event)"/>

                                    <s:TextInput y="108" x="21" color="#FFFFFF" text="Drag me around too!" borderVisible="false" contentBackgroundAlpha="0.0" fontSize="26" toolTip="Click text to edit CTRL + click to move" mouseDown="dragText(event)" mouseUp="releaseText(event)"/>

       

                </s:BorderContainer>

      </s:Application>