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

close book in event handler

Community Beginner ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

I need to close modified books in a event handler, but the dialog for save, dont save, cancel does not "wait" user input.

Ok, it's not very clear, i try to explain with code:

 

function closeBooks() {
    var books = app.books.everyItem().getElements();
    var i, ilen = books.length;

    for (i = 0; i < ilen; i++) {
        if (books[i].modified) {
            books[i].close(SaveOptions.ASK);
        }
    }
    alert('done');
}

if you call the closeBooks function everything works fine.

When the function is used as handler, the "done" message appears immediately... before the for loop complete.

try:

app.addEventListener('beforeQuit', closeBooks);

 

close InDesign having one or more modified books to see this (strange) behaviour.

 

A simple workaround (if there were no other solutions) is to use a custom dialog.

But i have to translate the message "do you want to save the changes to the book?" and I have found nothing with app.findKeyStrings().

 

Is there a list of the language-independent key strings?

 

thanks.

Roberto (InDesign CC2021 16.2.1 on MacOs Catalina 10.15.7)

TOPICS
Bug , Scripting

Views

113

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
no replies

Have something to add?

Join the conversation