Reply To: Ensure Dialog Is Closed Before Proceeding

#14323609
Jeremy Howard
Participant

Update – Issue Has Been Resolved!

I finally found the solution I was looking for after a whole bunch of digging around and reading. Here is what I figured out:

——————————————————————————————————–——————————————————————————————————–——————————————————————————————————–
var aDialog = new Window(‘dialog’, “Dialog Title”,);
aDialog.orientation: ‘column’
aDialog.preferredSize: [300,100]
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(1)
}

var dialogResult = aDialog.show()

if(dialogResult == 1){
app.doScript(mainFunction, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, “Undo Name”);
}else if (dialogResult== 2){
alert(“You clicked the Cancel button!”);
exit(0);
}

function mainFunction(){
app.selection = app.activeDocument.pageItems[0];
}
——————————————————————————————————–——————————————————————————————————–——————————————————————————————————–

This works as i was hoping and will run the function without that pesky error!

This article was last modified on December 8, 2019

Comments (0)

Loading comments...