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

onClick Callback not working

Explorer ,
Jan 04, 2023 Jan 04, 2023

Copy link to clipboard

Copied

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

 

TOPICS
Scripting

Views

274

Translate

Translate

Report

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
Enthusiast ,
Jan 04, 2023 Jan 04, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Explorer ,
Jan 04, 2023 Jan 04, 2023

Copy link to clipboard

Copied

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. 

Votes

Translate

Translate

Report

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
Enthusiast ,
Jan 04, 2023 Jan 04, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Explorer ,
Jan 06, 2023 Jan 06, 2023

Copy link to clipboard

Copied

LATEST

Thanks for that tip. I'd been using the other option to launch it so never got the debugging. You solved two problems!

Votes

Translate

Translate

Report

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