Copy link to clipboard
Copied
Something like the following would work
var sel = app.selection[0]
if (sel.constructor.name != "TextFrame") {
alert("Selection is not a textframe")
exit()
}
if(sel.nextTextFrame == null && sel.previousTextFrame == null)
alert("You selected the one and only frame")
if(sel.nextTextFrame != null && sel.previousTextFrame == null)
alert("You selected the first frame")
if(sel.nextTextFrame != null && sel.previousTextFrame != null)
alert("You selected the frame in the middle")
if(sel.nextTextFr
...
HI @dublove ,
all your text frames ( other page items as well ) have a unique ID value.
So you could determine all the text frames' id values of a given story and compare the id value of the one of your selection to a specific one of the text frames of a story:
var selectedTextFrame = app.selection[0] ;
var idOfSelectedTextFrame = selectedTextFrame.id ;
var parentStory = selectedTextFrame.parentStory ;
var allTextContainersArray = parentStory.textContainers ;
for( var n=0; n < allTextContai
...
Copy link to clipboard
Copied
This get the 3 text frames of story 1. The 3rd text frame’s overflows returns true
//A collection of the document’s stories
var s = app.activeDocument.stories;
//the parentTextFrames of the first story’s text—3 in this case
var fs = s[0].texts[0].parentTextFrames
$.writeln(fs.length)
for (var i = 0; i < fs.length; i++){
if (i == 0) {
$.writeln("This is the first text frame, overflows are " + fs[0].overflows)
} else if (i == 1){
$.writeln("This is the second text frame, overflows are " + fs[1].overflows)
} else if (i == 2){
$.writeln("This is the third text frame, overflows are " + fs[2].overflows)
}
};
/*
returns:
3
This is the first text frame, overflows are false
This is the second text frame, overflows are false
This is the third text frame, overflows are true
*/
Copy link to clipboard
Copied
Hi rob day.
It's not like this.
I need to determine whether the currently selected textFrame is the first, middle, or last one.
Sometimes there may be only one textFrame.
Copy link to clipboard
Copied
Something like the following would work
var sel = app.selection[0]
if (sel.constructor.name != "TextFrame") {
alert("Selection is not a textframe")
exit()
}
if(sel.nextTextFrame == null && sel.previousTextFrame == null)
alert("You selected the one and only frame")
if(sel.nextTextFrame != null && sel.previousTextFrame == null)
alert("You selected the first frame")
if(sel.nextTextFrame != null && sel.previousTextFrame != null)
alert("You selected the frame in the middle")
if(sel.nextTextFrame == null && sel.previousTextFrame != null)
alert("You selected the last frame")
-Manan
Copy link to clipboard
Copied
That's it.
previousTextFrame
nextTextFrame
Manan Joshi Thank you very much.
Copy link to clipboard
Copied
@rob day @m1b I corrected my initial question.
II thought of a way to determine this based on three different scenarios.
However, it still seems impossible to determine which one I currently selected from fs[i].
The loop can only determine the order of the text boxes, but it cannot determine which text box is currently selected.
Is it possible to use A\. .\Z to determine this?
If A\. or .\Z cannot be found, it is the textFrame in the middle. I only need these three situations.
I don't know how to do this.
Copy link to clipboard
Copied
HI @dublove ,
all your text frames ( other page items as well ) have a unique ID value.
So you could determine all the text frames' id values of a given story and compare the id value of the one of your selection to a specific one of the text frames of a story:
var selectedTextFrame = app.selection[0] ;
var idOfSelectedTextFrame = selectedTextFrame.id ;
var parentStory = selectedTextFrame.parentStory ;
var allTextContainersArray = parentStory.textContainers ;
for( var n=0; n < allTextContainersArray.length; n++ )
{
if( allTextContainersArray[n].id == idOfSelectedTextFrame )
{
alert( "Selected frame found. Frame "+ (n+1) + " in the story is selected." );
break;
}
};
Or you could directly compare the text frames of the story to the one that is selected.
If you do this with the array of textContainers you first have to resolve the textContainer you like to compare with getElements() like below :
var selectedTextFrame = app.selection[0] ;
var parentStory = selectedTextFrame.parentStory ;
var allTextContainersArray = parentStory.textContainers ;
for( var n=0; n < allTextContainersArray.length; n++ )
{
if( allTextContainersArray[n].getElements()[0] == selectedTextFrame )
{
alert( "Frame "+ (n+1) + " in the story is selected." );
break;
}
};
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now