Adobe 0046100128056 - InDesign - Mac Manual page 107

Javascript
Table of Contents

Advertisement

C
6: Text and Type
HAPTER
The following script fragment shows how to add alternating row formatting to a table (for the complete
script, see AlternatingRows):
//Given a table "myTable," apply alternating fills to the table.
myTable.alternatingFills = AlternatingFillsTypes.alternatingRows;
myTable.startRowFillColor = myDocument.swatches.item("DGC1_446a");
myTable.startRowFillTint = 60;
myTable.endRowFillColor = myDocument.swatches.item("DGC1_446b");
myTable.endRowFillTint = 50;
The following script fragment shows how to process the selection when text or table cells are selected. In
this example, the script displays an alert for each selection condition, but a real production script would
then do something with the selected item(s). (For the complete script, see TableSelection.)
if(app.documents.length != 0){
if(app.selection.length != 0){
switch(app.selection[0].constructor.name){
}
}
}
//When a row, a column, or a range of cells is selected,
//the type returned is "Cell"
case "Cell":
alert("A cell is selected.");
break;
case "Table":
alert("A table is selected.");
break;
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
if(app.selection[0].parent.constructor.name == "Cell"){
alert("The selection is inside a table cell.");
}
break;
case "Rectangle":
case "Oval":
case "Polygon":
case "GraphicLine":
if(app.selection[0].parent.parent.constructor.name == "Cell"){
alert("The selection is inside a table cell.");
}
break;
case "Image":
case "PDF":
case "EPS":
if(app.selection[0].parent.parent.parent.constructor.name == "Cell"){
alert("The selection is inside a table cell.");
}
break;
default:
alert("The selection is not inside a table.");
break;
Working with Tables 107

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs5

Table of Contents