Copy link to clipboard
Copied
Thsi Script exports PDF files to a given folder without saving the current AI-file.
When one of the dialoge windows is open, I can navigate through the options and choose them with space-key. So the button gets blue higlighted but the predefined keeps its white outline. But hitting "Return" an the blue colored button, will not work at all. It will activate the white outlined button.
Space will activate the blue higlighted instead, like one would expect it from "Retrun", too.
Any idea how to capture "Return" when choosing e.g. "Abbrechen" in this dialogue?
function askDocumentChoice() {
var dlg = new Window("dialog", "Welche Dokumente speichern?");
dlg.add("Group {orientation:'row', alignment:['fill','top']}").add("statictext", undefined, "Sollen alle geöffneten Dokumente gespeichert werden?");
dlg.add("Group {orientation:'row', alignment:['fill','top']}").add("statictext", undefined, "(oder nur das aktuelle?)");
var buttonRow = dlg.add("Group {orientation:'row', alignment:['right','top']}");
var btnCurrent = buttonRow.add("button", undefined, "Nur aktuelles");
var btnAll = buttonRow.add("button", undefined, "Alle", { name: 'ok' });
var btnCancel = buttonRow.add("button", undefined, "Abbrechen", { name: 'cancel' });
btnCurrent.onClick = function() { dlg.close(0); };
btnAll.onClick = function() { dlg.close(1); };
btnCancel.onClick = function() { dlg.close(-1); };
dlg.defaultElement = btnAll;
dlg.cancelElement = btnCancel;
dlg.center();
return dlg;
}
Copy link to clipboard
Copied
Maybe this can work for you: to force it to do the desired flow by utilizing both the click and the onActivate.
function test(){
var w = new Window("dialog");
var btn_ok = w.add("button", undefined, "Ok");
var btn_ok2 = w.add("button", undefined, "Ok-2");
var resultAction = "NO";
function setActionBtn1 () {
resultAction = "Action from Button 'Ok'";
}
function setActionBtn2 () {
resultAction = "Action from Button 'Ok-2'";
}
btn_ok.onActivate = setActionBtn1;
btn_ok2.onActivate = setActionBtn2;
btn_ok.onClick = function () {
setActionBtn1();
w.close();
};
btn_ok2.onClick = function () {
setActionBtn2();
w.close();
};
if (w.show() != 2) {
alert(resultAction);
}
};
test();
Copy link to clipboard
Copied
> Run Script
> press Tab twice to hightlight "OK-2"
> press Enter
>> get message "OK" but it should be "OK-2"
I accept that it does not work this way and use it as it is.
Copy link to clipboard
Copied
Maybe there are some local-specific nuances, but I was unable to reproduce your result.
For me, the above always shows the correct corresponding message.
@m1b are you able to confirm the same for the latest snippet I have pasted by any chance?
Copy link to clipboard
Copied
Hi @Silly-V when I perform OPs test on your script:
> Run Script
> press Tab twice to hightlight "OK-2"
> press Enter
>> get message "OK" but it should be "OK-2"
I get the same result as OP, which is expected behaviour (for me!). I don't agree that "it should be OK-2".
But I think OP has now reconciled with the way it works. Good luck with your scripting @0771 !
Copy link to clipboard
Copied
I don't know at this point, maybe it is a bug with my one computer -- because when I tab twice, whether I do Enter or Space, it always says "Action from Button 'Ok-2'" when I get the Ok-2 highlighted.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now