Answered
Is there a more efficient way to distinguish where the cursor is located?
Hello everyone.
I feel that this method is not efficient.
Also, I'm puzzled why this sentence can't be written like this:
if (item instanceof (InsertionPoint || Text || Character || Word || Paragraph || TextColumn || TextStyleRange || Line || Table || Cell)) { return 'in' }I've written everything, it feels a bit too much. Don't these Word Paragraph Character Lines all belong to "Text"?
var d = app.activeDocument;
var item = d.selection[0];
var curStatus = curStatus();
alert(curStatus);
function curStatus() {
if (item instanceof InsertionPoint
|| item instanceof Text
|| item instanceof Character
|| item instanceof Word
|| item instanceof Paragraph
|| item instanceof Line
|| item instanceof TextColumn
|| item instanceof TextStyleRange
|| item instanceof Table
|| item instanceof Cell
) { return 'in' }
//if (item instanceof (InsertionPoint || Text || Character || Word || Paragraph || TextColumn || TextStyleRange || Line || Table || Cell)) { return 'in' }
if (!item) { return 0; }
else { return 'out'; }
}
Also, can you use one sentence of code to distinguish whether the cursor is inside or outside the table?
