Inspiring
January 12, 2024
Answered
Script UI help for InDesign
- January 12, 2024
- 2 replies
- 2176 views
Hi
This is the first script I have written for UI. I am stuck at two places.
I have a drop down which shows all the paragraph styles available in my document.
There is a static text at the left side of the dropdown which acts as a label.
There is another statictext on the right side of the dropdown which I want to populate with the selected option from the dropdown.
Issue 1: How to populate it with the selected text.
Issue 1: How to bring that static text at the right side, below the dropdown and above the buttons.
//Get handle to active document
var myDoc=app.activeDocument;
//Get list of para styles defined in the document and store the arrow in a variable
var paraNames = myDoc.paragraphStyles.everyItem().name;
//Create a window object
var myWindow = new Window("dialog","List of Paragraph Styles");
//Change the orientation of Window from column to row. Column is DEFAULT
//Row shows side by side.
//myWindow.orientation = "row";
//Create two groups. One for the dropdown and the other for buttons
myInfoGroup = myWindow.add("group");
myButtonGroup = myWindow.add("group");
//Add items to groups
myInfoGroup.add("statictext",undefined,"List of Paragraph styles");
//Add dropdown List
var myDropdown = myInfoGroup.add("dropdownlist",undefined,paraNames);
myInfoGroup.add("statictext",undefined,"Selected item");
//default display of the dropdown
myDropdown.selection=0;
//Add buttons to myButtonGroup
var btnOK = myButtonGroup.add("button",undefined,"OK");
var btnCancel = myButtonGroup.add("button",undefined,"Cancel");
btnOK.onClick = function(){
alert("do some processing");
};
btnCancel.onClick = function(){
myWindow.close(0);
};
//Show the window
myWindow.show();
