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

Detect in a Script When an Empty Table and Closed Up to Hide the Text Marker

Engaged ,
Jul 11, 2023 Jul 11, 2023

Copy link to clipboard

Copied

I have a script that is checking some things in table cells, one of which is the baseline of the first line of text.

 

Is there a way to detect when a cell is empty, but it isn't big enough to show the end-of-text marker? Trying to get the baseline of such a cell causes an error, which makes perfect sense, and I've been unable to find a way to detect that scenario.

 

Thanks

TOPICS
Scripting

Views

270

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 , Jul 12, 2023 Jul 12, 2023

Hi @KenWK 

 

quote

Is there a way to detect when a cell is empty, but it isn't big enough to show the end-of-text marker?

 

Let myCell be the Cell instance and ips its .insertionPoints property (ips=myCell.insertionPoints). Your condition can be expressed as:

 

    1 == ips.length && 'undefined' == typeof(ips[0].properties.baseline)

 

Note. – The bad news is that this test transiently involves the ips[0].property object, which is legendaryly inefficient like any other command sent to the Text components of a

...

Votes

Translate

Translate
Community Expert ,
Jul 11, 2023 Jul 11, 2023

Copy link to clipboard

Copied

Have you looked at cell.overset?

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 ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

JavaScript have try...catch for this. 

 

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 ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

Hi @KenWK 

 

quote

Is there a way to detect when a cell is empty, but it isn't big enough to show the end-of-text marker?

 

Let myCell be the Cell instance and ips its .insertionPoints property (ips=myCell.insertionPoints). Your condition can be expressed as:

 

    1 == ips.length && 'undefined' == typeof(ips[0].properties.baseline)

 

Note. – The bad news is that this test transiently involves the ips[0].property object, which is legendaryly inefficient like any other command sent to the Text components of a Table. I think it should still be a bit faster than the try...catch approach suggested by Robert, but it would be worth confirming with a timed test.

 

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
Engaged ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

Sorry, brianp311, I meant to mention in my original post that when the cell is empty the overset returns False.

 

Great suggestion Marc, thanks, may check it out at some point. For the limited scope I need right now it is currently working with a try catch that targets the error that gets thrown (which is something like "not applicable in the current state") but I was hoping to get more specific, which your suggestion does.

 

While investigating I saw something on an Adobe page that mentioned "uncomposed" text so I thought maybe I was missing some way of detecting when something was "uncomposed."

 

Thanks everyone!

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 ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

Derp. Would have realized that in a caffeinated state 😉 Glad Marc came through. 

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
Engaged ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

LATEST

😆

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