skip to Main Content

Why is this not working?

...
var newFolder = inputGroup.add ("group");
var newIFolder = newFolder.add("edittext",[0, 0, 300, 20]);
var addButton =  newFolder.add ("button", undefined, "Add");


var closeButton = window.add ("button", undefined, "Close");

closeButton.onClick = function() {
    window.close();}

addButton.onClick = function() {
    return newIFolder.text;
    window.close();
    alert(newFolder.text);}
...

Nothing happens onClick, the window just remains open.

Perhaps it’s because of the groupings, somehow. I’ll try to move it on top level, while I wait.

Thanks in advance and best regards.

Edit: On top level no change 🙁
Edit2: I’ve tried, but no change 🙁

var addButton =  window.add ("button", undefined, "Add", {name: "ok"});

2

Answers


  1. Chosen as BEST ANSWER

    Final solution ended like this:

    var newFolder = inputGroup.add ("group");
    var newIFolder = newFolder.add("edittext",[0, 0, 300, 20]);
    var addButton =  newFolder.add ("button", undefined, "Add", {name: "ok"});
    
    var closeButton = window.add ("button", undefined, "Close", {name: "cancel"});
    
    addButton.onClick = function() {
        window.close();
        var inputFile = newIfolder.text;}
    

    Once again, Thank you very much :D


  2. Here is exactly the code I just tried and it works fine for me (InDesign 2022, Illustrator 2023, Photoshop 2023):

    var window = new Window ("dialog");
    // var newFolder = window.add ("group");
    var newIFolder = window.add ("edittext",[0, 0, 300, 20]);
    var addButton =  window.add ("button", undefined, "Add");
    var closeButton = window.add ("button", undefined, "Close");
    
    closeButton.onClick = function() {
        window.close();
    }
    
    addButton.onClick = function() {
        window.close();
        alert(newIFolder.text);
        return newIFolder.text; // <-- probably the problem was here
    }
    
    window.show();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search