@dublove said: "This is merely an initial state check: if(item.constructor.name==“Text”). It's not the final result. The desired outcome is that, in this state, after running the script, the text box's column should be selected."
Hi @dublove ,
maybe I was confused a bit and did not read all you said properly.
So I'm asking if the following statements describe what you want to start with:
Scenario 1:
The user did a text selection in a table cell, but only one insertion point long; so to say, the "cursor sits in the cell".
Action: Select all body cells of that column. Regardless if the table rows are running through one or a number of text frames.
For this case use this code:
//SCENARIO 1:
if
(
app.selection[0].insertionPoints.length == 1
&&
app.selection[0].parent.constructor.name == "Cell"
)
{
var table = app.selection[0].parent.parent;
var headerRowCount = table.headerRowCount;
var footerRowCount = table.footerRowCount;
app.select
(
app.selection[0].parent.parentColumn.cells.itemByRange
(
headerRowCount ,
-( footerRowCount + 1 )
)
);
};
Scenario 2
The user did a text selection in a table cell, but this time one or more characters.
Action: Select all body cells of that column that are positioned in the current text frame.
//SCENARIO 2:
if
(
app.selection[0].insertionPoints.length > 1
&&
app.selection[0].parent.constructor.name == "Cell"
)
{
var textFrame = app.selection[0].insertionPoints[0].parentTextFrames[0];
var rangeOfCells =
app.selection[0].parent.parentColumn.cells.everyItem().getElements();
var cellsToSelect = [];
for( var n=0; n<rangeOfCells.length; n++ )
{
if
(
rangeOfCells[n].rowType == RowTypes.BODY_ROW
&&
rangeOfCells[n].insertionPoints[0].parentTextFrames[0] == textFrame
)
{
cellsToSelect[ cellsToSelect.length++ ] = rangeOfCells[n];
}
};
app.select( cellsToSelect[0] );
for( var n = 1 ; n < cellsToSelect.length; n++ )
{
app.select( cellsToSelect[n] , SelectionOptions.ADD_TO )
};
};
Regards, Uwe Laubender ( Adobe Community Expert )
... View more