Skip to main content
March 6, 2009
Answered

[JS, CS3] How can I deselect text?

  • March 6, 2009
  • 2 replies
  • 1171 views
Hi fellow scripters,

I just wrote a script that works beautifully, finding a portion of text within a selection and replacing it with a variable. However, at the end of the script it leaves the new text selected. Is there a way to deselect this and leave the cursor at the end of the new text? I tried to use SelectionOptions.REMOVE_FROM but it gives me an error stating that 'Remove from Selection' option not supported for this object type. What could I be doing wrong? Thanks for any help.

Regards,

Len Swierski
This topic has been closed for replies.
Correct answer Peter Kahrel
You place the cursor somewhere by selecting that insertion point. It could be something like this:
>app.selection[0].insertionPoints[-1].select()

To get the cursor at the end of your selection and deselect whatever was selected. To leave the cursor at the beginning of whatever was selected, use [0] instead of [-1].

Peter

2 replies

March 6, 2009
Peter,

That did it! Thanks so much.

Regards,

Len Swierski
Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
March 6, 2009
You place the cursor somewhere by selecting that insertion point. It could be something like this:
>app.selection[0].insertionPoints[-1].select()

To get the cursor at the end of your selection and deselect whatever was selected. To leave the cursor at the beginning of whatever was selected, use [0] instead of [-1].

Peter