Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now