Hello all!
I have been struggling with an issue that has been driving me nuts for a while and I am hoping someone can help!
Let’s say that I have a button in a custom dialog (such as “Continue”) that should close the active dialog and run a function. If I try something like this:
——————————————————————————————-
var aDialog = new Window(‘dialog’, “Window Name”);
aDialog.preferredSize = [300,100];
aDialog.orientation = ‘column’;
aDialog.add(‘statictext’, undefined, “Some dialog contents here.”);
var myButtonGroup = aDialog.add(‘group’);
var cancelButton = myButtonGroup.add(‘button’, undefined, “Cancel”,{name: “Cancel”});
var proceedButton = myButtonGroup.add (‘button’, undefined, “Continue”,{name: “proceedButton”});
proceedButton.onClick = function() {
aDialog.close();
app.doScript(mainFunction, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, “Main Function”);
}
aDialog.show()
function mainFunction(){
app.selection = app.activeDocument.pageItems[0];
}
——————————————————————————————————–
Then I will get an error in my function that says, “Cannot handle the request because a modal dialog or alert is active”. This is very confusing to me because I very clearly told the dialog to close prior to running the function.
My workaround has been to use palettes instead of dialogs but the same sort of issue can occur there as well. For example, I am currently working on a script where I am using a palette that should probably be a dialog. I want the palette to close and I want a progress bar to show when I click “Continue” on that palette. Instead, what I get is a frozen view of the main palette for the first 1/3 of the called function and a progress bar that displays once the script is already 33% done.
Ideally, I would just get this working properly as a dialog but I’ll take what i can get at this point.
Here are my specs:
Mac OS X 10.13.6
InDesign 2020 (15.0)