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

Scripting: Can I delay (or prevent) quitting InDesign?

Participant ,
Aug 05, 2020 Aug 05, 2020

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

TOPICS
Scripting

Views

237

Translate

Translate

Report

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

correct answers 2 Correct answers

Engaged , Aug 07, 2020 Aug 07, 2020

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

...

Votes

Translate

Translate
Community Expert , Aug 07, 2020 Aug 07, 2020

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);
}

 

 

 

Votes

Translate

Translate
Engaged ,
Aug 07, 2020 Aug 07, 2020

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.

 

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

LATEST

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);
}

 

 

 

Votes

Translate

Translate

Report

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