-
How to detect multiple OK buttons in Script UI dialogue box
In the code below, I can’t seem to target which button was pressed. Both “Option 1” and “Option 2” should behave like OK buttons (do some code and close the window). What am I doing wrong? Thanks!
var myWindow = new Window ("dialog");
myWindow.add ('statictext', undefined, 'Mode:', {multiline: false});// some more window input options
myWindow.add ("button", undefined, "Option 1", {name: "ok"});
myWindow.add ("button", undefined, "Option 2", {name: "ok"});
myWindow.add ("button", undefined, "CANCEL", {name: "cancel"});if (myWindow.show () == 0) {
alert("You chose Option 1");
//execute some code and close the window
}
if(myWindow.show () == 1){
alert("You chose Option 2");
//execute some code and close the window
}
if(myWindow.show () == 2){
alert("You chose Cancel");
exit ();
}