scripting opening a file from a a dropdown menu using system.call
Hello,
I am working on a script with a UI window and a dropwodn list. the dropdown populates with a list of files and folder from a certian locaiton on our server. I would like to use the selected dropdown item as a variable that I can open, maybe post a screenshot to the folder, export too, etc. Right now my code populates the dropwon with a server location, and the selection is a variable and I am attemping to use the "go" button to open the selected using a system.callSystem method which contains the path plus the selected item variable name I don't think I have the order or the proper syntax of the function right to open the selected item. I'm sure I'm missing somehting but is ther a way to make this work, or a differnt way to go about it? I have posted my code below Any help is much appreciated.
{
function myScript(thisObj) {
function myScript_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Dockable Script", undefined, { resizeable: true, closeButton: false });
res = "group{orientation:'column',\
groupOne: Group{orientation:'row',\
dropDown: DropDownList{},\
},\
groupThree: Group{orientation:'row',\
refreshButton: Button{text:'Refresh'},\
closeButton: Button{text:'Close'},\
goButton: Button{text:'Go'},\
},\
}";
myPanel.grp = myPanel.add(res);
//Defaults
myPanel.grp.groupOne.dropDown.size = [200, 25];
myPanel.grp.groupThree.refreshButton.onClick = function() {
populateDropDown(myPanel.grp.groupOne.dropDown, Folder("/Volumes/AgencyServer/Transfer").getFiles());
}
myPanel.grp.groupThree.closeButton.onClick = function() {
myPanel.close();
}
myPanel.grp.groupThree.goButton.onClick = function () {
system.callSystem("open /Volumes/AgencyServer/Transfer/" + "dd.selection");
}
myPanel.layout.layout(true);
return myPanel;
}
var myScriptPal = myScript_buildUI(thisObj);
if (myScriptPal != null && myScriptPal instanceof Window) {
myScriptPal.center();
myScriptPal.show();
}
}
myScript(this);
}
function populateDropDown(dd, array){
dd.removeAll();
for(var i = 0; i < array.length; i++){
dd.add("item", array[i].name.replace(/%20/g, " "));
}
dd.selection;
}
