launching a secondary window

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
slawes
Posts: 25
Joined: December 9th, 2006, 12:38 pm
Location: LA, California

July 5th, 2007, 1:08 pm

I have this weird problem with lauching a secondary window, and its kind of a chicken/egg syndrome.
First off, the secondary window get's shown before the main UI - I can somewhat figure out why (even though in theory it should only get shown when the .onChange argument is met) , but i can't then figure on where to put the .show command ?
Secondly, when the user chooses a different item from the 'dropdown' the info window pops up twice.

This is part of a larger script, so I broke out just the part that isn't working.

many thanks,
Steve.

clearOutput();

var proj = app.project;
var projColl = proj.items;
var myComps = new Array();
var selItems = app.project.selection;
if (selItems.length > 0){
var myColl = app.project.selection;
var i = 0;
} else {
var myColl = new Array();
for (j=0; j < projColl.length; j++){
myColl[j] = projColl[j+1];
}
}

w = buildUI();
compsettings();
w.show();

function buildUI() {

win = new Window('dialog', 'Slate Tool',[100,100,650,660]);
win.infopnl = win.add('panel', [20,225,530,375], 'Info');
win.infoList = win.infopnl.add('dropdownlist', [20,20,320,40]);
win.infoList.onChange = function () {
winfo = new Window('dialog','info' ,[200,200,650,400]);
winfo.infopnl = winfo.add('edittext',[20,20,430,180], '');
winfo.show();
}

win.cancel = win.add('button', [21,520,101,540], 'Cancel', {name:'Cancel'});
win.cancel.onClick = function () { write("cancel"); }
win.ok = win.add('button', [150,520,230,540], 'OK', {name:'OK'});
win.ok.onClick = function () {

//the rest of the script goes here
write("done");
}
return win;
}

function compsettings() {
win.infoList.selection = null;
win.infoList.removeAll();
win.infoList.add("item", 'none');
for (i=0; i <= myColl.length-1; i++) {
win.infoList.add("item", myColl[i].name);
}
win.infoList.selection = 0;
}
Post Reply