Skip to main content
Participant
April 19, 2024

Cannot add controls in another function if window is pallete type

  • April 19, 2024
  • 5 replies
  • 527 views

Good day. I have found a problem where you cannot add controls in another function if you are using a pallete window type. Have a look at this example.

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

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

 This code will only work if the window is a `dialog` type. If it is a `palette` type, it won't work. With `palette` the window flickers for a milisecond and then goes away. This is a small example, but in practise this is quite a large hinderance to a project. It means you cannot reuse any UI building logic in multiple places. Is there any temporary solution to this issue?

This topic has been closed for replies.

5 replies

JohnColombo17100380
Community Manager
Community Manager
May 7, 2024

Thank you for the follow-up, @Francois36853938zmve, and for the workaround, @Airweb_AE. We are able to reproduce the issue as well, even in the legacy ExtendScript ToolKit on Windows separate from After Effects, and have now opened a ticket to investigate the root cause.

 

Thanks again,

- John, After Effects Engineering Team 

Participant
April 23, 2024

I tested what @Airweb_AE  said and their trick works perfectly well. See the code below.

 

var parentWindow = new Window("palette", "Parent");
var parentPanel = parentWindow.add("panel", undefined, "Panel Title");
parentPanel.alignment = "fill";
var myButton = parentPanel.add("button", undefined, "Open UI");
myButton.onClick = function () {
    var childWindow = new Window("palette", "Child");
    var childPanel = childWindow.add("panel", undefined, "Panel Title");
    childPanel.alignment = "fill";
    addButton(childPanel);
    childWindow.show();
    // childWindow.onClick = function(){};
}
parentWindow.show();

function addButton(panel) {
    panel.add("button", undefined, "OK");
}
Participant
April 23, 2024

@Airweb_AE what console do you have open there in your video? How can I open it myself?

 

Legend
April 22, 2024

I also noticed this bug.

It occurs when there isn't a click event in your code.

If you save and run this code in test.jsx, it works as expected.

However, if you generate the palette dynamically using a button, it doesn't work, you need to add a click event somewhere to fix it.

 

var palette = new Window("palette", "test", undefined, { resizeable: true })
var button = palette.add("button", undefined, "OK", { name: "button1" });
palette.show();

//palette.onClick = function(){}

 

 [ VIDEO ] 

JohnColombo17100380
Community Manager
Community Manager
April 22, 2024

Hi @Francois36853938zmve,

Thank you for reporting this issue. The code you've posted doesn't appear to run as written—would you be able to post an expanded snippet that reproduces the issue? 

 

It would also help us to know what the overall desired behavior is for your script panel. E.g. a button that opens another panel or dialog.

 

Have you been able to do what you've described in a previous version of After Effects? It would be helpful for us to know if this is a recent breakage.

 

Thanks again for reporting and for any additional information you can provide,

- John, After Effects Engineering Team