0 Replies Latest reply on Oct 2, 2008 4:52 AM by Highland Matt D

    dragging from TextInput -> TextInput

    Highland Matt D
      In my app I'd like a drag from a TextInput to another TextInput to default to a "move" operation rather than a "copy". I've overridden the enter, over, drop and complete events as shown in the code below. With this code in place it almost works, but when the mouse is near the edge of the TextInput control, for some reason the cursor turns into the "copy" cursor and if I complete the drag/drop while in this state and then click on the what was the drag source, AIR initiates another drag sequence which always results in that control's contents being lost.

      A related question, which if I knew the answer to I might be able to figure the rest out, is, how does drag and drop work with TextInput controls? From a quick perusal of the code, I don't see either the TextInput or the UITextField code listening for drag/drop related events at all.

      Here's my code (note that all TextInput controls have these registered as for their event corresponding events):

      private function onItemWeekDragEnter(e:NativeDragEvent):void
      {
      e.dropAction = NativeDragActions.MOVE;
      NativeDragManager.acceptDragDrop(e.currentTarget as flash.display.InteractiveObject);
      }

      private function onItemWeekDragOver(e:NativeDragEvent):void
      {
      e.dropAction = NativeDragActions.MOVE;
      NativeDragManager.acceptDragDrop(e.currentTarget as flash.display.InteractiveObject);
      }

      private function onItemWeekDragDrop(e:NativeDragEvent):void
      {
      if (e.dropAction == NativeDragActions.MOVE || e.dropAction == NativeDragActions.COPY)
      {
      var dragTarget:TextInput = e.currentTarget as TextInput;
      var uiTextField:UITextField = dragTarget.getChildAt(1) as UITextField;
      dragTarget.text = uiTextField.text;
      ItemUpdateEvent(dragTarget);
      }
      }

      private function onItemWeekDragComplete(e:NativeDragEvent):void
      {
      if (e.dropAction == NativeDragActions.MOVE)
      {
      var dragSource:TextInput = e.target.parent as TextInput;
      dragSource.text = "";
      ItemUpdateEvent(dragSource);
      }
      }

      Thanks in advance for any help you can provide.

      --matt