Skip to main content
DeviantPain12
Participant
July 12, 2019
Answered

How is the selection array sorted?

  • July 12, 2019
  • 1 reply
  • 353 views

Hi all,

I am trying to change the positions of selected text frames through JavaScript.

Using app.activeDocument.selection I am able to retrieve the array of selected items.

For example, in this selection:

app.activeDocument.selection[0] returns the text frame containing "Top Title"

app.activeDocument.selection[1] returns the text frame containing "Bottom Caption"

app.activeDocument.selection[2] returns the text frame containing "1"

app.activeDocument.selection[3] returns the text frame containing "D"

However, I can't reliably determine which index of the array gives me a particular text frame.

How is this order determined? If it is random, how would I be able dynamically differentiate each text frame?

This topic has been closed for replies.
Correct answer Kasyan Servetsky
However, I can't reliably determine which index of the array gives me a particular text frame.

How is this order determined? If it is random, how would I be able dynamically differentiate each text frame?

It reflects the order in which you selected the objects.
Check out this post.

— Kas

1 reply

Kasyan Servetsky
Kasyan ServetskyCorrect answer
Legend
July 12, 2019
However, I can't reliably determine which index of the array gives me a particular text frame.

How is this order determined? If it is random, how would I be able dynamically differentiate each text frame?

It reflects the order in which you selected the objects.
Check out this post.

— Kas