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

Is there any way, so that I could place the cursor in a selected text using javascript in illustrator.

Explorer ,
Apr 26, 2018 Apr 26, 2018

Hi,

I had selected a text using script. Now I need to place the cursor somewhere in the selected text. Is it possible?
Thanks in advance.

TOPICS
Scripting
831
Translate
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
Adobe
Community Expert ,
May 01, 2018 May 01, 2018

It's hard to work with insertion points in Illustrator. Most things are read only.

I think, all that I can give you and what could be useful is this (select a text frame before)

app.activeDocument.selection[0].insertionPoints[0].characters.add("\u0041");

Have fun

Translate
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
Explorer ,
May 01, 2018 May 01, 2018

Hi pixxxel,
Thank-you for your response. That worked fine. But, my requirement is to have a cursor somewhere in the selected textframe.

Translate
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 ,
May 01, 2018 May 01, 2018

Sorry, but this is the closest thing that I know. The problem is: you cannot select the type tool afterwards and then funny things happen with the selection if the user want to write something after running the script.

There is IMHO no solution at the moment.

Translate
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 ,
Mar 30, 2022 Mar 30, 2022
LATEST

Hello, I think there is a way to do so.

 

Bildschirmfoto 2022-03-30 um 10.28.30.png

 If you use this code snippet:

// replace selection or add at position of the cursor
var vDocRef = app.activeDocument;
var vSelection = vDocRef.pageItems;
var vText = vSelection[0];
var vNewChars = "xx";
// .textSelection[0] = where the cursor is
vText.textSelection[0].contents = vNewChars; 
vText.textRange.deSelect(); // deselect if you like
Translate
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