Skip to main content
Byron Nash - INSP
Inspiring
January 4, 2023
Question

onClick Callback not working

  • January 4, 2023
  • 1 reply
  • 605 views
 This is a snippet from the UI setup of a script I have. This is after generating the panel and in the section where I'm defining all the callbacks and settings for the UI. My other onClick functions on other buttons are working. But this one won't open the project like I'm asking it to.  I need help spotting my error. 

 

    myPanel.grp.groupOne.groupTwo.openProjectButton.onClick = function () {
        var projFile = new File(prefLoad("Template Project", 2));//my prefload function is returning a valid file path
        alert("trying to open the project at " + projFile);//this alert was showing the file path until I inserted the new File() into the variable
       
        try {
            app.open(projFile);
          } catch (err) {
            alert(err);// nothing comes up with this error
          }
    }

 

This topic has been closed for replies.

1 reply

Inspiring
January 4, 2023

What is prefLoad returning? Presumably a file path? But then if you were previously returning a file path string into projFile but then added 'new File' that turned it into a File object, your alert probably isn't going to like that (i.e. should be projFile.path in alert perhaps). Although if you're using a debugger I would expect it to flag that.

Byron Nash - INSP
Inspiring
January 4, 2023

Yes, it's returning a file path stored as a string in preferences. Changing the alert to use the .path parameter seems to fix it. I'm not sure why im' not getting any debugging with my setup. I'm using Visual Studio Code with the Extendscript Debugger installed. When there is a minor error like you spotted, it just won't run and gives no feedback. 

Inspiring
January 4, 2023

You're going into VScode's 'Run and Debug' section and clicking 'Attach to Extendscript Engine' then seeing the bar at the bottom turn orange? Just a simple $.writeln("hello world"); script should verify it's being sent back to the VScode Debug Console.

To be honest it's all a bit fiddly and confusing getting it set up and working. And if you're on an OS that still supports the old Extendscript Toolkit and that ever gets a chance to launch, you then have to quit and relaunch AE to get it to allow a VScode session.