Highlighted

InDesign

New Here ,
Oct 21, 2020

Copy link to clipboard

Copied

Hi friends,

when clicking the button the selected items of list box should get deselected & deselected items get selected from list box? Can any one tell me.....

TOPICS
Bug, Scripting

Views

88

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

InDesign

New Here ,
Oct 21, 2020

Copy link to clipboard

Copied

Hi friends,

when clicking the button the selected items of list box should get deselected & deselected items get selected from list box? Can any one tell me.....

TOPICS
Bug, Scripting

Views

89

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 21, 2020 0
Adobe Community Professional ,
Oct 21, 2020

Copy link to clipboard

Copied

Show us the sample code that you have, only then can we give proper suggestions.

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 21, 2020 0
New Here ,
Oct 22, 2020

Copy link to clipboard

Copied

Thank you for ur reply Manan Joshi,

Here is the code, 

when clicking the reverse selection button the items present in the listbox should get selected and the unselected items should get selected?

 

// GROUP2
// ======
var group2 = panel1.add("group", undefined, {name: "group2"});
group2.preferredSize.width = 200;
group2.orientation = "column";
group2.alignChildren = ["left","center"];
group2.spacing = 10;
group2.margins = 0;

var statictext1 = group2.add("statictext", undefined, undefined, {name: "statictext1"});
statictext1.text = "Please select Preset/Presets";

var button2 = group2.add("button", undefined, undefined, {name: "button2"});
button2.text = "Reverse Selection";

button2.addEventListener("click",function(event){
if(button2.text == "Reverse Selection") {
listbox1.selection = 0;
}
else(button2.text !== "Reverse Selection"){
listbox1.clearSelection = false;
}
});
var presetList = [];
for(var fp = 0; fp < app.pdfExportPresets.length; fp++){
presetList.push(app.pdfExportPresets[fp].name.toString());
}

var listbox1 = group2.add ("listbox", undefined, undefined, {name: "listbox1", items: presetList, multiselect: true});
listbox1.selection = 0;
listbox1.preferredSize.width = 179;

 

If you know means please reply me..........

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
New Here ,
Oct 22, 2020

Copy link to clipboard

Copied

Screenshot (1).png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Adobe Community Professional ,
Oct 22, 2020

Copy link to clipboard

Copied

The following code for the button click handler should do the job.

button2.addEventListener("click",function(event)
{
	for(var i = 0; i < listbox1.items.length; i++)
	{
		var a = listbox1.items[i]
		listbox1.items[i].selected = !listbox1.items[i].selected
	}
});

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 2
New Here ,
Oct 22, 2020

Copy link to clipboard

Copied

Thanks a lot Manan!! ur code works.perfectly. thank u so much.............

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
New Here ,
Oct 22, 2020

Copy link to clipboard

Copied

And one more doubt can you solve this?

.    When Export button is pressed, pdf should export and naming conventions of pdf file/s will be like ["InDesignFileName_PresetSelected_LayerSelected.pdf"]

 

Note : If user is selecting 2 preset & 1 layer so total 2 pdf will be generated etc.

 

Here is my code,

 

var myDoc = app.documents[0];
for(var i = 0; i < myDoc.layers.length; i++){
myDoc.layers[i].visible = false;
}
for(var i = 0; i < myDoc.layers.length; i++){
var layerName = myDoc.layers[i].name;
myDoc.layers[i].visible = true;
app.activeDocument.exportFile(ExportFormat.pdfType, File(myDoc.filePath.fsName.replace(/\\/g,'/')+"/"+myDoc.name.replace(/\.indd/g,'')+"_"+layerName+".pdf"),false);
$.writeln(myDoc.filePath.fsName.replace(/\\/g,'/')+"/"+myDoc.name.replace(/\.indd/g,'')+"_"+layerName+".pdf");
myDoc.layers[i].visible = false;
}

 

pls refer the above screenshot which I had sent...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Adobe Community Professional ,
Oct 22, 2020

Copy link to clipboard

Copied

Place your export code in a loop that runs according to the length of the listbox's selection property.

listbox1.selection.length

The above would give you the total number of selected elements in the listbox.

Then you can access the text of each selected entry as the following

listbox1.selection[0].text

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0