Window within a panel
Posted: September 9th, 2013, 2:27 pm
Hi all, I've been away from After Effects scripting for awhile, and now when I'm back I struggle with what I expect to be a simple task. I'm trying to create a new Window by clicking a button in my main Panel. However the new window closes as soon as it has been created. If I put an alert afterwards I see that it is created. Any ideas?
Code: Select all
function myScript(thisObj) {
var pal = (thisObj instanceof Panel) ? thisObj : new Window("palette", "script", undefined);
if (pal != null) {
var res=
"Group { \
orientation: 'column', \
alignment: ['fill', 'fill'], \
alignChildren: ['left', 'top'], \
minimumSize: [125, 26],\
one: Group { \
orientation: 'row', \
new_window: Button {text: 'create new window', size: ['120', '25']}, \
} \
}";
pal.grp = pal.add(res);
pal.layout.layout(true);
pal.layout.resize()
pal.grp.one.new_window.onClick = function () {
newWindow ();
}
return pal;
} // if (pal != null) {
} // function myScript_buildUI(thisObj) {
function newWindow() {
var win = new Window("palette");
if (win != null) {
var res=
"Group { \
orientation: 'column', \
alignment: ['fill', 'fill'], \
alignChildren: ['left', 'top'], \
minimumSize: [125, 26],\
one: Group { \
orientation: 'row', \
new_button: Button {text: 'new button', size: ['100', '25']}, \
} \
}";
win.grp = win.add(res);
win.layout.layout(true);
win.layout.resize()
win.show()
alert("A window is behind me and will close as I close this.")
} // if (pal != null) {
} // function myScript_buildUI(thisObj) {
ui = myScript()
ui.show()