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:
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)
Have something to add?