Skip navigation
Currently Being Moderated

Drop an URL on a InDesign document from a Flex panel

Jan 13, 2012 5:54 AM

Tags: #flex #drag-and-drop

Hi Everyone,

 

I have a Flex panel, in InDesign, from which I drag an URL. If I drop this URL on a text editor or a web browser, it works. But when I try to drop it on my InDesign document, it's a little bit harder.

 

I have implemented a subclass of CDragDropTargetFlavorHelper. The drop works perfectly on Windows. But on mac, I have problems in the method CouldAcceptTypes :

 

DragDrop::TargetResponse

AutocatDNDCustomFlavorHelper::CouldAcceptTypes(const IDragDropTarget* target, DataObjectIterator* dataIter, const IDragDropSource* fromSource, const IDragDropController* controller) const

{

               if (0 != dataIter && 0 != target)

               {

 

            DataExchangeResponse response = dataIter->FlavorExistsWithPriorityInAllObjects(kURLDExternalFlavor);

                              if (response.CanDo())

                              {

           

            }

      }

}

 

The problem is that response.canDo() answers kTrue on Windows, but kFalse on Mac. I tried to explore the content of dataIter, but a call on dataIter->First() returns nil. I tried a controller->GetItemCount(), which returns 1. But if I try a controller->GetDragItem(1), I get a nil pointer. I have the impress there is no item.  Though, the drop works on another app than InDesign, as I said.

 

Is it a problem of internalization ? Or something else ? It let me dry.

 

Thanks in advance

 
Replies
  • Currently Being Moderated
    Jan 13, 2012 6:10 AM   in reply to perigee_rde

    Hi,

     

    if CanDo returns kFalse for the flavor kURLDExternalFlavor then retry it with kURLExternalFlavor.

     

    Markus

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 19, 2012 12:39 PM   in reply to perigee_rde

    Are there any specific reasons why you chose GetDragItem(1) rather than GetDragItem(0) ?

    Actually you should iterate the items, from 0 upto GetItemCount()-1 ...

     

    Dirk

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 20, 2012 4:07 AM   in reply to perigee_rde

    My use of GetDragItem is only in experimental code of a development plugin and I did not verify that for your case.

     

    I have a production plugin though that accepts browser drag&drop of links. My approach was to substitute the links during Internalize with some download to be placed by the standard file dropping place helper, thus I did not use GetDragItem at all. Internalize already receives the IPMDataObject ...

     

    Browsers deliver many flavors at the same time, different even by the kind of object the link is bound to. In that plugin I had to do severe shuffling (ReorderFlavors during multiple helpers) to get the whole thing to work - I think kSysFileDataExchHandlerNetscapeHelperBoss was stealing away anythink resembling a link at highest priority.

     

    The original debug session was 5 years ago with InDesign 2 so I don't remember the nifty details, and just pray that nothing breaks when I have to do another port or support another browser. From that experience I remember the whole InDesign D&D mechanism is an overcomplicated mess of too many phases, but still insufficiently factored in the later phases.

     

    Dirk

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 1, 2012 7:04 AM   in reply to perigee_rde

    In your CouldAcceptTypes function, you get access to the  IPMDataObject via  dataIter->First() Here you can read out the content as either  kTEXTExternalFlavor or kUNICODETEXTExternalFlavor, depending on what you like the best. At this point you can also check if it actually something that is your, if you prefix from Flex or is looking for a specific string format. Store the result in a static variable and you can use this once you get called in ProcessDragDropCommand.

     

    Thomas

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points