Hi All,
I'm trying to write a script for indesign CS6 mac which will open a panel and let me interact with it while indesign is open. I've tried several different code approaches, and with all of them, the window briefly opens and then closes immediately. If I add an infinite loop into the mix, it does not close, but remains unresponsive. This is one version of the code:
#target inDesign
#targetengine main
function myScript(thisObj) {
function myScript_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "My Panel Name", [0, 0, 300, 300]);
res="group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
myStaticText: StaticText{text:'StaticText Text'},\
myEditText: EditText{text:'EditText text'},\
myButton: Button{text:'Button Name'},\
myCheckbox: Checkbox{text:'Checkbox Name'},\
myRadioButton: RadioButton{text:'RadioButton Name'},\
myDropDownList: DropDownList{properties:{items:['Item 1 Name', 'Item 2 Name', 'Item 3 Name', 'Item 4 Name']}},\
myListBox: ListBox{properties:{items:['Item 1 Name', 'Item 2 Name', 'Item 3 Name', 'Item 4 Name']}},\
myGroup: Group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
myGroupItem1: Button{text:'Hi'},\
myGroupItem2: Button{text:'Hello'},\
myGroupItem3: Button{text:'Goodbye'},\
},\
myPanel: Panel{text:'Panel Name', orientation:'column', alignChildren:['right', 'fill'],\
myPanelItem1: Button{text:'One'},\
myPanelItem2: Button{text:'Two'},\
myPanelItem3: Button{text:'Three'},\
},\
myProgressBar: Progressbar{text:'Progressbar Name', minvalue:0, maxvalue:100, value:50},\
}"
app.addEventListener("afterSelectionChanged", onSelChg, false );
//Add resource string to panel
myPanel.grp = myPanel.add(res);
// DropDownList default selection
myPanel.grp.myDropDownList.selection = 2;//Item index starts at 0
//Setup panel sizing and make panel resizable
myPanel.layout.layout(true);
myPanel.grp.minimumSize = myPanel.grp.size;
myPanel.layout.resize();
myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}
return myPanel;
}
var myScriptPal = myScript_buildUI(thisObj);
if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
myScriptPal.center();
myScriptPal.show();
}
}
myScript(this);
function onSelChg()
{
alert("hi");
}
Any ideas?
Thanks!
Arïel wrote:
To get a palette to stay open, you need (apart from setting an
independent target engine, which you've done) to run if from the
InDesign scripts palette. If you try to run it from ESTK it won't work.
Ariel
This was my experience in CS4 and previous—it wouldn't work if the engine didn't already exist. In CS5 and above, though, it will create the engine on the fly even from the ESTK.
OP should use a targetengine other than "main", though.
Jeff
North America
Europe, Middle East and Africa
Asia Pacific