Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Event Listener for Drag & Drop on ExtendScript

New Here ,
Sep 25, 2017 Sep 25, 2017

Hi all,

Does anyone know if ExtendScript has any event listeners for when something outside of InDesign (aka not a CEP Extension) is dragged inside? I'm building a desktop app and I'm hoping to drag and drop images into InDesign from my app but wasn't sure if that was possible.

I have taken a look at the Object Model Viewer to see the list of Events available and have tried playing with "beforePlace", but that event fires later than I'd want. I also understand it might be possible to do something similar with Drag & Drop by building an InDesign Plugin but I have no knowledge of C++ so I was hoping to avoid that route. Any help would be appreciated!

Thanks in advance

TOPICS
Scripting
2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 27, 2017 Sep 27, 2017

Hello,

There is no "dragAndDrop" event in ExtendScript that I know of but it's easy to mimick such events by using beforeImport event (to catch the asset's url) and afterSelectionChanged event (fired when user actually clicks on the page to place the asset).

Here is a possible approach:

#targetengine "pseudoDragnDropListener"

var placed = null;

var main = function() {

var

onBeforeImportListener = app.eventListeners.itemByName ( "onBeforeImport" ),

onAfterSelectionChangedListener = app.eventListeners.itemByName ( "onAfterSelectionChanged" ),

onBeforeImportHandler = function(evt){

var doc = evt.parent;

if ( !(doc instanceof Document ) ) return;

placed = evt.fullName;

},

onAfterSelectionChangedHandler = function(evt){

if ( placed ) {

alert("you just placed "+placed );

placed = null;

}

};

if ( !onBeforeImportListener.isValid ) {

onBeforeImportListener = app.eventListeners.add("beforeImport", onBeforeImportHandler );

onBeforeImportListener.name = "onBeforeImport";

}

if ( !onAfterSelectionChangedListener.isValid ) {

onAfterSelectionChangedListener = app.eventListeners.add("afterSelectionChanged", onAfterSelectionChangedHandler );

onAfterSelectionChangedListener.name = "onAfterImport";

}

}

main();

HTH

Loic

Ozalto | Productivity Oriented - Loïc Aigon

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 27, 2017 Sep 27, 2017

Hi Loic!

Thanks for your help and for replying back. I just played with "beforeImport" and it seems like that event only fires when a file (or at least not text) is imported into the document =[ . I'll have to take a look to see if there are specific listeners for text that is placed into the Document.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 28, 2017 Sep 28, 2017
LATEST

Then you can work with idleEvents to monitor close to real time what is happening inside indesign. Stories collection can change, storirs contents can change.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines