-
Dockable GUI issues – load dropdownlist from array
Hey guys,
Im working on my first dockable GUI panel but im running into issues.
Im building this mainly by sticking pieces of code from the web together, with a more than basic understanding of javascript, but nothing special.I decided to load my dockable window using a resource string, as I read that was the best option if you want to create a dockable window. Fine, but terribly documented and hardly anything to be found online. Just my luck ☺
Anyways, what im trying to do is load a dropdownlist into my window, which is filled with the names of all the layers from a comp called ‘master’.
I think I can figure it out in regular scripting, but this resource string is really making it hard for me. Does anyone know how to tackle this?If not, can anyone point me in the right direction of creating a dockable window without the use of a recourse string?
My code at the moment looks like this:
var masterComp;
for (var i = 1; i <= app.project.numItems; i ++) {
if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name === 'master')) {
masterComp = app.project.item(i);
break;
}
}
var myList = new Array();// UI Code
{
function myScript(thisObj) {
function myScript_buildUI(thisObj){
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "My window name", undefined,{resizeable:true});for(var i=1; i <= masterComp.numLayers; i++){
myList[myList.length] = masterComp.layer(i).name;
}res = "group{orientation:'row',\
groupOne: Group {orientation:'column',\
masterButton: Button{text:'Master'},\
layerButton1: Button{text:'First Name'},\
layerButton2: Button{text:'Last Name'},\
layerButton3: Button{text:'Gender'},\
layerButton4: Button{text:'Phonenumber'},\
layerButton5: Button{text:'Email'},\
layerButton6: Button{text:'Work'},\
layerButton7: Button{text:'Streetname'},\
layerButton8: Button{text:'Housenumber'},\
layerButton9: Button{text:'City'},\
layerButton10: Button{text:'Subs'},\
DDL: DropDownList {items:'+myList+'},\,\
},\
}";myPanel.grp = myPanel.add(res);
myPanel.layout.layout(true);
// return window
return myPanel;
}
var myScriptPal = myScript_buildUI(thisObj);
if((myScriptPal != null)&&(myScriptPal instanceof Window)){
myScriptPal.center();
myScriptPal.show();
}}
myScript(this);
}
I removed a couple of pages of functions that are linked to the buttons, but i hope you get the idea.
The main culprit is this line: DDL: DropDownList {items:’+myList+’},\
I tried many different approaches, but all end up in errors, or no dropdownlist at all.It appears that “myList” is filled with the proper names of the layers, since it gives an array of names when i do something like alert(myList);
Even our ITers are like….i dont really want to dive into this mess – but im hoping someone can point me into the right direction ????
Cheers guys!