Skip to main content
Participating Frequently
October 21, 2023
Question

HELP ME RE-DOING THIS SCRIPT AS A DOCKABLE PANEL?

  • October 21, 2023
  • 1 reply
  • 1284 views

It is not working as a dockable panel, and it is launching two windows. I NEEED HELP! 

// Function to add or update text in the composition
function updateTextInComp(text) {
var comp = app.project.activeItem;

if (comp && comp instanceof CompItem) {
// Check if a text layer already exists
var textLayer = null;
for (var i = 1; i <= comp.layers.length; i++) {
if (comp.layers[i] instanceof TextLayer) {
textLayer = comp.layers[i];
break;
}
}

if (textLayer) {
textLayer.property("Source Text").setValue(text);
} else {
textLayer = comp.layers.addText(text);
textLayer.property("Position").setValue([comp.width / 2, comp.height / 2]);
textLayer.startTime = comp.time;
}
} else {
alert("Please select or create a composition first.");
}
}

 

// Create UI panel
var win = new Window("palette", "Text Editor");
win.size = [400, 300];
win.alignChildren = ["fill", "fill"];

 

// Title
var title = win.add("statictext", undefined, "Text Editor");
title.alignment = "center";
title.graphics.font = ScriptUI.newFont("Verdana", "BOLD", 16);

 

// Text Input
var textInput = win.add("edittext", undefined, "", {
multiline: true,
scrolling: true,
enterKeySignalsOnChange: true
});
textInput.size = [undefined, 200];
textInput.graphics.backgroundColor = textInput.graphics.newBrush(
textInput.graphics.BrushType.SOLID_COLOR, [0.2, 0.5, 0.1]
);
textInput.graphics.foregroundColor = textInput.graphics.newPen(
textInput.graphics.PenType.SOLID_COLOR, [0.9, 0.9, 0.9], 1
);

 

// Update Button
var updateButton = win.add("button", undefined, "Update Text");
updateButton.alignment = "center";

updateButton.onClick = function () {
var text = textInput.text;
updateTextInComp(text);
};


win.show();

This topic has been closed for replies.

1 reply

Mathias Moehl
Community Expert
Community Expert
October 21, 2023
Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Leo BledoAuthor
Participating Frequently
October 24, 2023

Yeah but it didn't work, or I couldn't figure it out. It is not displaying a dockable panel, besides that it is opening two windows, one as a dockable one but empty and the main one but is not dockable. What I can do?

Mathias Moehl
Community Expert
Community Expert
October 24, 2023

Best post the code you tried in as a reply in the other discussion. Then we can take a look at the code and maybe spot what needs to be fixed. 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects