• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
6

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

Community Beginner ,
Oct 02, 2023 Oct 02, 2023

Copy link to clipboard

Copied

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?

TOPICS
Scripting

Views

307

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Oct 03, 2023 Oct 03, 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 qu

...

Votes

Translate

Translate
Community Expert ,
Oct 02, 2023 Oct 02, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

Hi @brianp311 🙂 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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

LATEST

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2023 Oct 03, 2023

Copy link to clipboard

Copied

Hi @Marc Autret.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines