0

我有一个可拖动的组件。但是,如果用户在鼠标位于文本字段上时拖动,则无法拖动它。如何设置文本字段,以便用户可以单击并拖动界面的该部分?

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"  creationComplete="init()" width="210" height="150" styleName="noteStyle" >
<mx:Script>
    <![CDATA[
        public var testId:int;
        public var buttonNumber:int;
        public function init():void{
            this.addEventListener(MouseEvent.MOUSE_DOWN, makeDraggable)
            this.addEventListener(MouseEvent.MOUSE_UP, endDrag)
            this.buttonMode = true;
            this.useHandCursor = true;
        }
        public function saveButtonHandler():void{
            dispatchEvent(new Event  ( "noteClosed"));
        }
        public function cancelButtonHandler():void{
            dispatchEvent(new Event  ( "noteCancelled"));
        }
        public function makeDraggable(e:Event):void{
            //If the target and the current target are the same, then it must be the background, so make it draggable.
            //Stops the text field and buttons from being draggable
            trace("Target= "+e.currentTarget+" "+e.target)
            if(e.currentTarget==e.target){
                this.startDrag();
            }
        }
        public function endDrag(e:Event):void{
            this.stopDrag();
        }
    ]]>
</mx:Script>
    <mx:Text  text="Add a note: Drag to move"   styleName="myriadPro14"   selectable="false"   />
    <mx:Button  id="saveButton" label="Save" x="146" y="120" click="saveButtonHandler()" />
    <mx:Button  id="cancelButton" label="Cancel" x="10" y="120" click="cancelButtonHandler()"  />
    <mx:TextArea id="noteText" width="200" height="80"     horizontalCenter="0" verticalCenter="-12"/>
</mx:Canvas>
4

1 回答 1

0

也向文本字段添加事件侦听器。

于 2013-01-22T17:56:21.053 回答