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

Adding controls to a panel from a function in another file does not work

Community Beginner ,
Apr 19, 2024 Apr 19, 2024

Good day. I have a problem where, when you place your functions that add controls to a panel in another file, then they don't work. Have a look at this example:

 

This works fine (when everything is in one file):

# myFile.jsx

myButton.onClick = function () {
    var myWindow = new Window("dialog", "My Dialog");
    var myPanel = myWindow.add("panel", undefined, "Panel Title");
    myPanel.alignment = "fill";
    localAddButton(myPanel);
    myWindow.show();
}

function localAddButton(panel) {
    panel.add("button", undefined, "OK");
}

But this does not work (when things live in different files):

# myFile.jsx

#include "otherFile.jsx"
myButton.onClick = function () {
    var myWindow = new Window("dialog", "My Dialog");
    var myPanel = myWindow.add("panel", undefined, "Panel Title");
    myPanel.alignment = "fill";
    otherAddButton(myPanel);
    myWindow.show();
}

# --------------------------------------------------------------

# otherFile.jsx

function otherAddButton(panel) {
    panel.add("button", undefined, "OK");
}

Note that this is definitely not a problem with my include or paths or anything. I can import functions and variables just fine. This is a small example, but in practise this is quite a large hinderance to a project because it means all our tools need to live in one single file. Or we have to copy-paste the same functions into multiple files. Is there any temporary solution to this issue?

 

TOPICS
Scripting
102
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
no replies

Have something to add?

Join the conversation