EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - Working with Text Selections; Moving and Copying Text

Adobe 0046100128056 - InDesign - Mac
209 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 6: Text and Type Understanding Text Objects 83
For a text frame, the parent of the text frame usually is the page or spread containing the text frame. If the
text frame is inside a group or was pasted inside another page item, the
parent of the text frame is the
containing page item. If the text frame was converted to an anchored frame, the
parent of the text frame
is the character containing the anchored frame.
Working with text selections
Text-related scripts often act on a text selection. The following script demonstrates a way to determine
whether the current selection is a text selection. Unlike many of the other sample scripts, this script does
not actually do anything; it simply presents a selection-filtering routine that you can use in your own
scripts (for the complete script, see TextSelection).
if (app.documents.length != 0){
//If the selection contains more than one item, the selection
//is not text selected with the Type tool.
if (app.selection.length == 1){
//Evaluate the selection based on its type.
switch (app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Story":
//The object is a text object; pass it on to a function.
myProcessText(app.selection[0]);
break;
//In addition to checking for the above text objects, we can
//also continue if the selection is a text frame selected with
//the Selection tool or the Direct Selection tool.
case "TextFrame":
//If the selection is a text frame, get a reference to the
//text in the text frame.
myProcessText(app.selection[0].texts.item(0));
break;
default:
alert("The selected object is not a text object.
Select some text and try again.");
break;
}
}
else{
alert("Please select some text and try again.");
}
}
Moving and copying text
You can move a text object to another location in text using the move method. To copy the text, use the
duplicate method (whose arguments are identical to the move method). The following script fragment
shows how it works (for the complete script, see MoveText):

Table of Contents

Related product manuals