Drag and drop external text into a Flex component

Hi,
is there any way to allow drag and drop of external text (for
example, selected text from another browser or even from the
address bar) into a Flex component like TextArea? I know how to
drag and drop between two different Flex components but in this
case, the source is external. There must be something I can do to
TextArea like its dragdrop property to allow this feature... any
help would be greatly appreciated.
Thanks,
Josh

Short answer: Yes, as long as it is an AIR app.
Browser-based Flex apps do not have access to
ClipBoardFormats, so I'm not sure it is possible to do what I think
you want to do -- have a web-based Flex app that allows you to drag
and drop selected text from other apps. Most possibly because of
the security sandbox that the Flash player runs in.
However, if you wanted to do it in an AIR app, I built this
as an example for you (you can view a "cleaner" version with proper
indents at
http://pastebin.com/f741cbac8
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="
http://www.adobe.com/2006/mxml"
creationComplete="initDandD();" width="500" height="600">
<mx:Script>
<![CDATA[
public function initDandD():void {
addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,
onDragIn);
addEventListener(NativeDragEvent.NATIVE_DRAG_DROP,
onDragDrop);
private function onDragIn(e:NativeDragEvent):void {
if(e.clipboard.hasFormat(ClipboardFormats.TEXT_FORMAT)) {
NativeDragManager.acceptDragDrop(this);
private function onDragDrop(e:NativeDragEvent):void {
var myString:String =
e.clipboard.getData(ClipboardFormats.TEXT_FORMAT) as String;
myTextArea.text = myString;
]]>
</mx:Script>
<mx:TextArea id="myTextArea" width="326"
height="262"/>
</mx:WindowedApplication>

Similar Messages

  • Trying to drag and drop a text parameter, but it only applies to one letter

    Hiya,
    In Motion 3, you could drag and drop a Text - Style Parameter to another text object.
    Now, in Motion 4, when I try to drag a Parameter it only applies to the first letter of my text object.
    So when I drag my Glow from one object to another, my Bleary In Behavior has a blue glow on T in THIS and a yellow glow on HIS in THIS.
    I'm guessing this has to do with the ability to adjust each letter with the glyph tool. However, it won't allow me to drag the Parameter to each individual letter...
    Which I see a need for...
    But why would I want to do a time consuming thing like that?
    It's stupid.
    Any advice is much appreciated!
    Thank you

    Well, I'm not sure what to say. I can't replicate your problem. I can drag the outline parameters onto a text object in the viewer, layers pane, or timeline and it copies it exactly as it did in Motion 3, over the entire text object.
    However, if I have the glyph tool selected and try to do the same thing, it crashes Motion 100% of the time.
    Neither situation is what you're reporting though. It helped me find a bug, and something to avoid however.
    Andy

  • Why cant I drag and drop my pictures into an order I want to display them

    Why can't I drag and drop my pictures into an order that I want to display them ? The 'manual sort' option does not seem to be 'lit' nor does the 'reset manual sort' what am I doing wrong please.
    ps
    Beginning to wish I had stuck with a PC !

    If you prefer a PC use it. No one here cares one bit
    As to iPhoto, unless you take a few minutes to actually learn how to use it then you will never be happy. Same with any new PC program that you do not understand. Or a new car for that matter
    A great place to start your education is here. http://www.apple.com/support/iphoto/
    As to your specific issue, trivial. Make an album of the photos and manually drag them to the order you want. Events simply do not work that way
    Try to drive your car in Park and you get nowhere because that is not how it works. Any time you use a product incorrectly you will have poor results
    LN

  • Drag and drop from Lightroom into Premiere doesn't work in Windows

    I recently switched from OSX to Windows and noticed that in Windows, I'm unable to drag and drop from LIghtroom into Premiere. In OSX, it worked fine.
    I do this a lot because it's a time saver. I basically use lightroom to find the photo or video clip I need for my editing project and then just drag in right on to the Premiere timeline. Now I have to do the extra step in Lightroom of "show in explorer", then drag the file from explorer to Premiere. Not really a big deal but just curious why it works in OSX and not Windows.
    I'm running latest Windows 8.1, Lightroom 5.4, Camera Raw 8.4, and Premiere Pro CC 7.2.2 (33)
    -Pete

    Hi Pete,
    You can obtain scripts here:
    http://www.robcole.com/Rob/ProductsAndServices/MiscLrPlugins#MiscScripts
    You'll have to edit lua code to adapt for Premiere. Not that hard really (e.g. clone, then change the script name and path to executable..), but may be too intimidating for some folks. If you are one of those folks, go for the plugin instead - it's usable via GUI - no lua code - can probably accomplish the same thing.
    http://www.robcole.com/Rob/ProductsAndServices/OpenInWhateverLrPlugin
    Let me know (outside the forum please) if problems - thanks,
    Rob

  • What's up when you drag and drop a table into a jsp page?

    Hi All,
    I was wondering what's happen in dragging and drop a table into a jsp page. This question because untill yesterday i had an application up and running, with a table displaying a number of rows of the database, and an action associated with an update into a database.
    The action is managed trough JNDI, defined from Preference-Embedded.......
    It was working.
    Then the machine hosting the db changed IP addres. I went into Webcenter Administration console, I've changed the connection string into the jdbc parameters, by updating the new IP address... but it's not working anymore! The log comes out with a big error, but basically it can't connect at the db!
    So, I think there is somewhere some reference to the old db.....where???
    Thanks
    Claudio

    Yes Shay,
    I got this error:
    JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.jbo.DMLException, msg=JBO-26061: Error while opening JDBC connection.
    in few hours I'll be able to give you the full stack.
    Thanks
    Clauido
    Message was edited by:
    user637862
    Hi Shay,
    Thanks a lot..you were right.
    I've located the ba4j on the webcenter server...and I've noticed that it was with the old address.
    I think it's a bug, cause on the local machine (before to deploy) this file comes with the right address.
    So next time, before to redeploy a new application, I think I'm going to fiscally delete the folder from j2ee folder.
    Thanks again for the help!
    Claudio

  • Can I drag and drop single photos into Events?

    Hi guys. I've very recently ordered a new Mac that will have iLife 08 on it. Before I get started with it I've got a question about Events. I've been using iPhoto for the last several years, organizing my photos into albums. I've cleaned up my images to around 1,000 photos, and I plan to only use events for organization. (I don't want to use Events AND albums, don't see the point, I'm going to try using ONLY Events.) But I've got a few scenerios that I'd like to throw by you all, to see if they would work, as I'm hoping that they will...
    I don't shoot photos into pre-defined "Events", I shoot photos by what I feel like shooting. "Hey, my dog is doing something funny" - There's 3 pictures, or "Wow that's a big spider!" - 1 picture, or "My little neice is doing something cute" - There's 4 pictures. I do not want 450 events, each containing 1 - 5 pictures.
    Can I drag and drop single pictures into different events? For example, have an Event called "Friends" with pictures of my friends in it, that I put there? Or an event called "Concerts" with photos taken throughout the years?
    I hope I've made it clear what I'm looking to get out of Events!
    Thanks in advance for any help.

    Exactly - I think he will want to matain his existing structure -- people are making too much of the name change from rolls to events.
    I have events with one photo and events with as many as 2000 photos -- I like this better than rolls but albums, folders and keywords are still the key to granular organization - events are ust the library to hold my photos
    To me it is a small step forward that makes organization much easier (and it was not that hard before)
    Larry Nebel
    PS - now if I could just get all of my edits to save - where are TD and OT to solve that one for me?

  • Drag and Drop Survey Link into Mail Forms

    Hi Experts,
    I have below client requirement regarding mail forms.
    Query:  Is it possible to drag and drop survey link into mail form ?
    To be best my knowledge we need to insert survey link manually into  mail form.
    Your help is highly appreciated.
    Thanks
    Mohit

    Hi Mohit,
    The drag and drop feature for inserting Surveys is currently not available in Mail form screen (to best of my knowings).
    Regards,
    Anup

  • Drag and drop FLAC audio into iPod to convert and add?

    I manually sort my music as albums in folder directories. I have never liked how iTunes wanted to sort my music back in 2005 and I don't like it any more today.
    I recently got a 6th gen iPod Nano via the 1st gen iPod Nano replacement program and I am disappointed in how I cannot use Winamp to manage my playlists anymore. Winamp would automatically transcode incompatible FLAC audio into MP3 before transferring onto my 1st gen Nano.
    I have my iPod options under iTunes set to automatically convert higher bitrate audio to 192kbps AAC, but dragging and dropping FLAC audio into my iPod gives an error message that prevents me from adding anything.
    I thought maybe I had to import my audio into iTunes' library first, but scanning for media adds every audio file including system and program audio files to my library, which really clutters things up. It treats each artist as an album, so compilation albums of 30 audio tracks from 30 artists appear as 30 individual albums in my iTunes library. Most cumbersome.
    I am also appauled in how it did not detect or support playback of FLAC audio. I am not willing to convert my entire library into a proprietary lossless audio format just because iTunes wants me to when other programs and I were getting along so well without iTunes and my 1st gen Nano.
    Anyway, what I am hoping to achieve is to find a streamlined way to convert FLAC audio files into MP3 or AAC while I am transferring them to my iPod without having to involve another program to manually convert before adding. This is a huge convenience factor for which I am regretting having my 1st gen Nano replaced. I will admit that I am perhaps being overly stubborn here. Maybe I'll just sell this 6th gen Nano while it's still pristine and get a Sansa Clip or something. Apple products have become too stifling and I won't be surprised if there was no way to achieve what I am asking to do here, so maybe this ends up a being more of a rant than a search for answers.

    foobar2000 with the ipod plugin will allow you to drag/drop FLAC files and when it syncs the ipod, it converts the FLAC files on the fly. MUCH better than dealing with the crappy iTunes interface and having to pre-convert the files. I absolutely loathe iTunes and it just gets worse and worse!

  • Drag and drop the text and image

    Hi,
    I need help in drag and drop text and image.
    I am able to drag and drop the text and image in doc but  i want to drag the text in text frame and image in image frame only.
    For this how to get textframe id or is there any other way to do this. Pls help me if anyone know how to do this one.
    Thanks
    Arun

    This thread is pretty old, but this can help anyone in the future:
    To handle a drop in InDesign, you have to implement your own custom CDragDropTargetFlavorHelper. You can find a working example in SDK Sample. Take a look at BasicDragDrop.sdk project in the SDK.

  • Why can I no longer drag and drop .mid files into GB?

    I can no longer drag and drop .mid files into GB. When I try, the track files flash and disappear. Please help
    Mac mini   Mac OS X (10.4.6)  

    found solution, thanx everyone

  • How to change this code to drag and drop image/icon into it??

    Dear Friends:
    I have following code is for drag/drop label, But I need to change to drag and drop image/icon into it.
    [1]. code 1:
    package swing.dnd;
    import java.awt.*;
    import javax.swing.*;
    public class TestDragComponent extends JFrame {
         public TestDragComponent() {
              super("Test");
              Container c = getContentPane();
              c.setLayout(new GridLayout(1,2));
              c.add(new MoveableComponentsContainer());
              c.add(new MoveableComponentsContainer());
              pack();
              setVisible(true);
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch (Exception ex) {
                   System.out.println(ex);
              new TestDragComponent();
    }[2]. Code 2:
    package swing.dnd;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    import java.awt.image.*;
    import java.awt.dnd.DragSource;
    import java.awt.dnd.DropTarget;
    public class MoveableComponentsContainer extends JPanel {     
         public DragSource dragSource;
         public DropTarget dropTarget;
         private static BufferedImage buffImage = null; //buff image
         private static Point cursorPoint = new Point();
         public MoveableComponentsContainer() {
              setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.white, Color.gray));
              setLayout(null);
              dragSource = new DragSource();
              ComponentDragSourceListener tdsl = new ComponentDragSourceListener();
              dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, new ComponentDragGestureListener(tdsl));
              ComponentDropTargetListener tdtl = new ComponentDropTargetListener();
              dropTarget = new DropTarget(this, DnDConstants.ACTION_MOVE, tdtl);
              setPreferredSize(new Dimension(400,400));
              addMoveableComponents();
         private void addMoveableComponents() {
              MoveableLabel lab = new MoveableLabel("label 1");
              add(lab);
              lab.setLocation(10,10);
              lab = new MoveableLabel("label 2");
              add(lab);
              lab.setLocation(40,40);
              lab = new MoveableLabel("label 3");
              add(lab);
              lab.setLocation(70,70);
              lab = new MoveableLabel("label 4");
              add(lab);
              lab.setLocation(100,100);
         final class ComponentDragSourceListener implements DragSourceListener {
              public void dragDropEnd(DragSourceDropEvent dsde) {
              public void dragEnter(DragSourceDragEvent dsde)  {
                   int action = dsde.getDropAction();
                   if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                   else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
              public void dragOver(DragSourceDragEvent dsde) {
                   int action = dsde.getDropAction();
                   if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                   else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
              public void dropActionChanged(DragSourceDragEvent dsde)  {
                   int action = dsde.getDropAction();
                   if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                   else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
              public void dragExit(DragSourceEvent dse) {
                 dse.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
         final class ComponentDragGestureListener implements DragGestureListener {
              ComponentDragSourceListener tdsl;
              public ComponentDragGestureListener(ComponentDragSourceListener tdsl) {
                   this.tdsl = tdsl;
              public void dragGestureRecognized(DragGestureEvent dge) {
                   Component comp = getComponentAt(dge.getDragOrigin());
                   if (comp != null && comp != MoveableComponentsContainer.this) {
                        cursorPoint.setLocation(SwingUtilities.convertPoint(MoveableComponentsContainer.this, dge.getDragOrigin(), comp));
                        buffImage = new BufferedImage(comp.getWidth(), comp.getHeight(), java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE);//buffered image reference passing the label's ht and width
                        Graphics2D graphics = buffImage.createGraphics();//creating the graphics for buffered image
                        graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));     //Sets the Composite for the Graphics2D context
                        boolean opacity = ((JComponent)comp).isOpaque();
                        if (opacity) {
                             ((JComponent)comp).setOpaque(false);                         
                        comp.paint(graphics); //painting the graphics to label
                        if (opacity) {
                             ((JComponent)comp).setOpaque(true);                         
                        graphics.dispose();
                        remove(comp);
                        dragSource.startDrag(dge, DragSource.DefaultMoveDrop , buffImage, cursorPoint, new TransferableComponent(comp), tdsl);     
                        revalidate();
                        repaint();
         final class ComponentDropTargetListener implements DropTargetListener {
              private Rectangle rect2D = new Rectangle();
              Insets insets;
              public void dragEnter(DropTargetDragEvent dtde) {
                   Point pt = dtde.getLocation();
                   paintImmediately(rect2D.getBounds());
                   rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
                   ((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
                   dtde.acceptDrag(dtde.getDropAction());
              public void dragExit(DropTargetEvent dte) {
                   paintImmediately(rect2D.getBounds());
              public void dragOver(DropTargetDragEvent dtde) {
                   Point pt = dtde.getLocation();
                   paintImmediately(rect2D.getBounds());
                   rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
                   ((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
                   dtde.acceptDrag(dtde.getDropAction());
              public void dropActionChanged(DropTargetDragEvent dtde) {
                   Point pt = dtde.getLocation();
                   paintImmediately(rect2D.getBounds());
                   rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
                   ((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
                   dtde.acceptDrag(dtde.getDropAction());
              public void drop(DropTargetDropEvent dtde) {
                   try {
                        paintImmediately(rect2D.getBounds());
                        int action = dtde.getDropAction();
                        Transferable transferable = dtde.getTransferable();
                        if (transferable.isDataFlavorSupported(TransferableComponent.COMPONENT_FLAVOR)) {
                             Component comp = (Component) transferable.getTransferData(TransferableComponent.COMPONENT_FLAVOR);
                             Point location = dtde.getLocation();
                             if (comp == null) {
                                  dtde.rejectDrop();
                                  dtde.dropComplete(false);
                                  revalidate();
                                  repaint();
                                  return;                              
                             else {                         
                                  add(comp, 0);
                                  comp.setLocation((int)(location.getX()-cursorPoint.getX()),(int)(location.getY()-cursorPoint.getY()));
                                  dtde.dropComplete(true);
                                  revalidate();
                                  repaint();
                                  return;
                        else {
                             dtde.rejectDrop();
                             dtde.dropComplete(false);
                             return;               
                   catch (Exception e) {     
                        System.out.println(e);
                        dtde.rejectDrop();
                        dtde.dropComplete(false);
    }Thanks so much for any help.
    Reagrds
    sunny

    Well, I don't really understand the DnD interface so maybe my chess board example will be easier to understand and modify:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=518707
    Basically what you would need to do is:
    a) on a mousePressed you would need to create a new JLabel with the icon from the clicked label and add the label to the glass pane
    b) mouseDragged code would be the same you just repaint the label as it is moved
    c) on a mouseReleased, you would need to check that the label is now positioned over your "drop panel" and then add the label to the panel using the panels coordinates not the glass pane coordinates.

  • I am trying to drag and drop my contacts into a numbers spreadsheet but it won't let me, can someone help?

    Hi
    So for my first project in numbers, I wanted to create a spreadsheet of all my contacts. I read the manual, watched a video tutorial, and tried just about everything I could think of, but I am un successful with dragging and dropping the contacts into a blank template. Can anyone help?

    Thanks for the feedback. You said you watched a video. Was it Gary's tutorial at MacMost.com? I really enjoyed that one.
    Jerry

  • Set default import format when drag and drop sound file into multitrack view?

    I've looked around the preference panels but cannot find where to set the import settings for dragging and dropping sound files into multitrack view. Some of our computers have correct settings and others do not. Thanks for your help!
    G

    I should have been more specific, sorry... I mean bit depth and bit rate... On some machines this defaults correctly and on other machines it is wrong. Not sure how to set these to downconvert properly by default. Unless it automatically takes the format of the source file, in which case it's just been luck.
    Thanks,
    G

  • Why I can't see the button fuse, when I drag and drop a folder into same name folder

    Why I can't see the button fuse, when I drag and drop a folder into same name folder
    I saw the option only one time, and i reseach in the internet and I find fuse option, but now never saw again.
    And Yes, I drag folders with the same name.

    Ok, Gracias por su pronta respuesta, yo necesito arrastar una carpeta a otra ubicacion con una carpeta del mismo nombre, entiendo que lion te advierte si desea reemplazar el contenido o fusionar (mexclar el contenido)
    como lo dice aqui :
    http://www.cioal.com/2011/06/29/las-cinco-novedades-mas-importantes-de-mac-os-x- lion/
    3. Podrás combinar tus archivos y carpetas. Seguro que alguna vez has perdido algún archivo al combinar carpetas o archivos del mismo nombre pero distinto contenido. Ahora, cuando intentes mover una carpeta a un lugar con otra de idéntico nombre, tu equipo te preguntará si prefieres combinar ambas o cambiar una por otra. Los archivos serán tratados de una manera similar: Cuando coincidan archivos con el mismo nombre, el sistema te preguntará también si quieres mantener ambas copias.
    y en muchas otras paginas que tratan el tema.
    mi problema es que esa opcion no me aparece. solo la opcion de reemplazar (o no reemplazar o detener)
    Lo increible es que alguna vez el mismo dia de hoy si me aperecio la opcion.

  • Why won't Premiere Pro allow me to drag and drop my footage into the timeline?

    why wont my software allow me to drag and drop my footage into the timeline?
    [Edit: the title of your post was changed to be more descriptive]
    Message was edited by: Kevin Monahan

    Get Started with Premiere Pro
    New to Premiere Pro? Get started with your first project — editing a video. In less than an hour, you'll learn to edit together different types of media to tell a video story.  

Maybe you are looking for

  • Oracle 9i Database and Developer Installation

    I am a student going through the Oracle Developer Certification and I am hoping someone can help me with some troubleshooting. This has to do with installing 2 different services on 2 home directories. I installed the Oracle 9i database enterprise ed

  • Will Photo Library Manager help without library file

    I recently upgraded to Leopard and added ilife to upgrade my iphoto from a reeaaally old version. I imported photos from the old version and Iphoto was working fine a couple weeks ago. Today, however, when I tried to open it, I got the Choose Your Li

  • White Balance and Color are off!!! NEF D80

    I was unable to get my images to appear as I shot them. I shoot with a Nikon D80 and shoot with a Vivid setting. Now after shooting a wedding of more than 1500 images I have to find a way to color correct them all. I have attempted the downgrade to t

  • Battery Swelling

    I purchased my MBP about a year ago around the time that the batteries had been having issue, i remember checking to make sure my battery wasn't one of them. Today i sat down at my computer and found it to be uneven after a few minutes of investigati

  • Screen stuck on gray, used shift key and my screen appears with MacBook Pro and not the recovery option. Please help

    Screen stuck on gray, used shift key and my screen appears with MacBook Pro and not the recovery option. Please help!