Skip to main content
Inspiring
July 12, 2023
Answered

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

  • July 12, 2023
  • 3 replies
  • 814 views

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

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

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

3 replies

Marc Autret
Marc AutretCorrect answer
Legend
July 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 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

KenWKAuthor
Inspiring
July 12, 2023

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!

brian_p_dts
Community Expert
Community Expert
July 12, 2023

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

Robert at ID-Tasker
Legend
July 12, 2023

JavaScript have try...catch for this. 

 

brian_p_dts
Community Expert
Community Expert
July 12, 2023

Have you looked at cell.overset?