Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

"Return" will not be captured with Script UI

Community Beginner ,
Nov 11, 2025 Nov 11, 2025

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;
}
TOPICS
Scripting
298
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Valorous Hero ,
Nov 11, 2025 Nov 11, 2025

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();
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 12, 2025 Nov 12, 2025

@Silly-V 

> 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 12, 2025 Nov 12, 2025

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 12, 2025 Nov 12, 2025

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".

Screenshot 2025-11-12 at 22.38.44.png

 

But I think OP has now reconciled with the way it works. Good luck with your scripting @0771 !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 12, 2025 Nov 12, 2025
LATEST

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.Recording 2025-11-12 063551.gif

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines