Window.show()
returns an integer, not a boolean. There are several key words like Ok
and Cancel
that Photoshop knows and buttons with these words return hardcoded values (1
for Ok
and 2
for Cancel
). You can set custom returns in .onClick()
:
var dlg = new Window("dialog");
// add buttons
dlg.add ("button", undefined, "OK");
var al = dlg.add ("button", undefined, "Close with custom return value");
dlg.add ("button", undefined, "Cancel");
al.onClick = function () {
dlg.close(10)
}
// show the dialog;
dlg.center();
var myReturn = dlg.show();
// Ok will alert 1
// Close with custom return value will alert 10
// Cancel will alert 2
alert(myReturn);
CLICK HERE to find out more related problems solutions.