Skip to main content
Participant
October 3, 2023
Answered

How to check if Paragraph / Line / Text / ... is overflowing

  • October 3, 2023
  • 2 replies
  • 775 views

Hi 🙂

 

I am looking for a way to detect if a particular range of text is overflowing.

 

I have found the "overflows" property on Story and TextFrame, but I am missing something similar on Paragraph / Line / Text / ...


Am I missing something, or does anyone have a good method to check this?

This topic has been closed for replies.
Correct answer Marc Autret

Hi @device cmyk,

 

Testing whether the last InsertionPoint of the text has no parent text frame should usually work:

 

function isOverset(/*Text*/tx)
//----------------------------------
// `tx` :: any valid, singular text object (Paragraph, Line, Word, Character...)
// => bool
{
   return !(tx.insertionPoints[-1].parentTextFrames||0).length;
}


// Test (assuming the selection has a parent story)
var word = app.selection[0].parentStory.words[-1];
alert( isOverset(word) );

 

But:

• It may not be the quickest method (?)

• A special treatment is required when tables/cells are involved.

 

Best,

Marc

2 replies

Marc Autret
Marc AutretCorrect answer
Legend
October 3, 2023

Hi @device cmyk,

 

Testing whether the last InsertionPoint of the text has no parent text frame should usually work:

 

function isOverset(/*Text*/tx)
//----------------------------------
// `tx` :: any valid, singular text object (Paragraph, Line, Word, Character...)
// => bool
{
   return !(tx.insertionPoints[-1].parentTextFrames||0).length;
}


// Test (assuming the selection has a parent story)
var word = app.selection[0].parentStory.words[-1];
alert( isOverset(word) );

 

But:

• It may not be the quickest method (?)

• A special treatment is required when tables/cells are involved.

 

Best,

Marc

Participant
October 3, 2023

Hi @Marc Autret.

Thank you for your answer! It's a big help!

brian_p_dts
Community Expert
Community Expert
October 3, 2023

Only a text frame or story overflows. How does a paragraph or line overflow if not in its containing frame? You can always look at a line or paragraphs parent text frames or parent story.

Participant
October 3, 2023

Hi @brian_p_dts 🙂 Excuse my imprecise wording.

 

What I want to check is if the text is visible in the container or not.

I am not interested in checking the state of the container but in the text itself.

 

I imagine something like "isOverset" – Sort of like the isValid-property.

Robert at ID-Tasker
Legend
October 3, 2023

But that's exactly how it needs to be done - and how @Marc Autret code works - checks for existence of a ParentTextFrame.