Copy link to clipboard
Copied
Hi,
I'm working on an Extension that does some checks on an Document. And I have an "beforeSave" listener that automatically does this when saving an document.
Works fine - the problem is in quitting InDesign. When the user quits InDesign and the document is not saved the user gets this "Save document" messagebox. User clicks "yes", document is saved and the extension is checking the document. But while checking Indesign is still quiting and my script can't finish the check of the document.
So my question: Is there a way to tell InDesign "Hey, don't quit! I'm working here!"? Or is there an "InDesign is quiting - don't start anything new"-flag that I can look for before I start my check?
Thanks
Klaus
Klaus:
Here's a snippet that allows the user to keep InDesign running if they have quit by mistake:
#targetengine session
app.eventListeners.add("beforeQuit",beforeQuitHandler)
function beforeQuitHandler(evt) {
if (!confirm("Do you want to quit now?")){
evt.preventDefault();
}// end if
}
Seems to me that you might want to (a) remove the confirm code so that this handler always calls preventDefault() and (b) use your beforeSave function to install or remove the beforeQuit event-listener as
...So my question: Is there a way to tell InDesign "Hey, don't quit! I'm working here!"? Or is there an "InDesign is quiting - don't start anything new"-flag that I can look for before I start my check?
Do you want to throw up a warning dialog or simply delay the quit? This would delay the quit for 5 sec.
#targetengine session
app.eventListeners.add("beforeQuit",beforeQuitHandler)
function beforeQuitHandler(evt) {
$.sleep(5000);
}
Copy link to clipboard
Copied
Klaus:
Here's a snippet that allows the user to keep InDesign running if they have quit by mistake:
#targetengine session
app.eventListeners.add("beforeQuit",beforeQuitHandler)
function beforeQuitHandler(evt) {
if (!confirm("Do you want to quit now?")){
evt.preventDefault();
}// end if
}
Seems to me that you might want to (a) remove the confirm code so that this handler always calls preventDefault() and (b) use your beforeSave function to install or remove the beforeQuit event-listener as needed.
Hope this helps.
Copy link to clipboard
Copied
So my question: Is there a way to tell InDesign "Hey, don't quit! I'm working here!"? Or is there an "InDesign is quiting - don't start anything new"-flag that I can look for before I start my check?
Do you want to throw up a warning dialog or simply delay the quit? This would delay the quit for 5 sec.
#targetengine session
app.eventListeners.add("beforeQuit",beforeQuitHandler)
function beforeQuitHandler(evt) {
$.sleep(5000);
}