ExtendScript use of prompt with buttons
I'm trying to build some sort of "Are you sure?" prompt in my script panels, but it wont ever recognise the "no" button. Addiditonally, if I use it more than once in a row it wont work correct any more - in a reduced test it opens a big empty window after the first one, in a larger script it disables my main window (just as if a dialog has been loaded), but does not show a window at all.
The base idea was to have a button in my main panel (window/palette) start a sub window (dialog), that "stops" the main panel for a moment when it's started so the user is forced to make a decision.
Here is the code, reduced to a demo with only the essential elements needed to replicate my problem:
// Create Main Window
myPanel = new Window ('palette');
myButton = myPanel.add('button {text:"Test"}');
var overWriteMe = true; // initialize
// Create Prompt Window
var promptWin = new Window ("dialog","Warning", undefined, {resizeable:false});
var promptWinYes = promptWin.add('button {text:"Yes"}');
var promptWinNo = promptWin.add('button {text:"No"}');
promptWinYes.onClick = function () {var overWriteMe = true; promptWin.close();} // If Yes button in prompt is clicked set var to true and close prompt
promptWinNo.onClick = function () {var overWriteMe = false; promptWin.close();} // If No button in prompt is clicked set var to false and close prompt
// If button "test" is clicked, start function "doSomething"
myButton.onClick = function (){doSomething();}
function doSomething(){
promptWin.center(); // build prompt (will be closed by prompt button)
promptWin.show();
if(overWriteMe == true){alert ("True");}
if(overWriteMe == false){alert ("False");}
}
myPanel.center();
myPanel.show();
First start:

After clicking Yes or No:

Every Click on Yes or No afterwards:

followed by the image above ("true").
